How do I refresh the page in ASP.NET? (Let it reload itself by code)

后端 未结 14 1844
悲&欢浪女
悲&欢浪女 2020-11-28 02:12

How do I refresh a page in ASP.NET? (Let it reload itself by code)

I\'d rather not use Response.Redirect() because I don\'t know if the page I will be on, as it\'s i

相关标签:
14条回答
  • 2020-11-28 02:49

    Once the page is rendered to the client you have only two ways of forcing a refresh. One is Javascript

    setTimeout("location.reload(true);", timeout);
    

    The second is a Meta tag:

    <meta http-equiv="refresh" content="600">
    

    You can set the refresh intervals on the server side.

    0 讨论(0)
  • 2020-11-28 02:50

    You can't do that. If you use a redirect (or any other server technique) you will never send the actual page to the browser, only redirection pages.

    You have to either use a meta tag or JavaScript to do this, so that you can reload the page after it has been displayed for a while:

    ScriptManager.RegisterStartupScript(this, GetType(), "refresh", "window.setTimeout('window.location.reload(true);',5000);", true);
    
    0 讨论(0)
提交回复
热议问题