views:

1043

answers:

4

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. Any help on this is greatly appreciated. Thanks in advance.

+1  A: 

I think this should do the trick (untested):

Page.Response.Redirect(Page.Request.Url.ToString(), true);
Fermin
+2  A: 

Response.Redirect(Request.Url.ToString());

Jack Marchetti
Watch out that can be used to do XSS exploits. You're blindly trusting the URL from the user. You'd be better off to do Response.Redirect( "~AbsolutePage.aspx" );
Nissan Fan
wow, never thought of that. Great point.
Jack Marchetti
A: 

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.

womp
-1 Asker said no Javascript
Josh Stodola
Wow, harsh. Pretty liberal with the downvotes there hey? He also said no redirects, and it was completely an aside to the rest of the answer.
womp
I didnt find the answer useful, so I clicked the down arrow. That's just what I do. No offense!
Josh Stodola
A: 

Depending on what exactly you require a Server.Transfer might be a resource-cheaper alternative to Response.Redirect. More info here.

Thomas Wanner