Refresh Page C# ASP.NET

后端 未结 10 696
别跟我提以往
别跟我提以往 2020-12-09 14:42

Is there a Page.Refresh type of command to refresh a page?

I don\'t want to redirect to the page or refresh in JavaScript.

相关标签:
10条回答
  • 2020-12-09 14:59

    Careful with rewriting URLs, though. I'm using this, so it keeps URLs rewritten.

    Response.Redirect(Request.RawUrl);
    
    0 讨论(0)
  • 2020-12-09 15:05

    Use:

    Response.Redirect(Request.RawUrl, true);
    
    0 讨论(0)
  • 2020-12-09 15:10

    You can just do a regular postback to refresh the page if you don't want to redirect. Posting back from any control will run the page lifecycle and refresh the page.

    To do it from javascript, you can just call the __doPostBack() function.

    0 讨论(0)
  • 2020-12-09 15:11

    I think this should do the trick (untested):

    Page.Response.Redirect(Page.Request.Url.ToString(), true);
    
    0 讨论(0)
  • 2020-12-09 15:11

    Depending on what exactly you require, a Server.Transfer might be a resource-cheaper alternative to Response.Redirect. More information is in Server.Transfer Vs. Response.Redirect.

    0 讨论(0)
  • 2020-12-09 15:13

    To refresh the whole page, but it works normally:

    Response.Redirect(url,bool) 
    
    0 讨论(0)
提交回复
热议问题