Self-redirection in ASP.NET is useful when you want to refresh your page. You can reset a page to it’s initial state in ASP.NET by redirecting to itself. Here are 3 ways you can do it:
3 Self-Redirection Examples
- Response.Redirect(Request.Path);
- The request path like the following form:
- /MyApp/MyFile.aspx
- The request path like the following form:
- Response.Redirect(Request.RawUrl);
- The path and any querystring parameters like the following form:
- /MyApp/MyFile.aspx?foo=bar
- The path and any querystring parameters like the following form:
- Response.Redirect(Request.Url.ToString());
- The path and querystring parameters are available as an absolute reference like the following form:
- http://MyServer/MyApp/MyFile.aspx?foo=bar
- The path and querystring parameters are available as an absolute reference like the following form:
A redirect does not do a postback, as a result, I consider it a hard refresh of the page.