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

asp.net

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 inside a user control inside a webpart inside sharepoint.

Best Answer

In my user controls, after updating data I do:

  Response.Redirect(Request.RawUrl);    

That ensures that the page is reloaded, and it works fine from a user control. You use RawURL and not Request.Url.AbsoluteUri to preserve any GET parameters that may be included in the request.

You probably don't want to use: __doPostBack, since many aspx pages behave differently when doing a postback.