During the process of serving a user’s request for a page data, we may need to redirect (send) him to another page for more processing. For example, if you are trying to access some content on the website that requires you to login first, then you would be redirected to the login page first. Another example is when you want to show a more detailed or richer content to the user but do not want the URL to change.
ASP.NET provides 2 distinct mechanisms for achieving the above 2 scenarios:
HttpResponse.Redirect (commonly known as Response.Redirect)
HttpResponse.Redirect method is more commonly known as Response.Redirect(…). The Response object is exposed on aspx pages by Page.Response property which is of type HttpResponse.
public void Redirect(
As the name implies, this method redirects/tells the user’s browser (client) to navigate to the new URL. You can specify the new URL and whether execution of the current page should terminate or not. Note that you can use both absolute URL and relative URL’s for the url parameter.
Note that ASP.NET performs the redirection by returning a 302 HTTP status code. A 302 response is generally indicative of “Moved Temporarily”. I will show you how to send a 301 response code (Moved Permanently) in a later blog post.
HttpServerUtility.Transfer (commonly known as Server.Transfer)
HttpServerUtility.Transfer method is more commonly known as Server.Transfer(..). The Server object is exposed on aspx pages by Page.Server property which is of type HttpServerUtility. These methods should be used in the case where you actually want to transfer the processing of the current request to another page without updating the user browser.
There are a couple of variations of this call:
public void Transfer(
public void Transfer(
If you set the preserveForm parameter to true, the target page will be able to access the view state of the previous page by using the PreviousPage property.
To summarize, HttpResponse.Redirect method redirects/tells the user’s browser (client) to navigate to the new URL. In contrast, HttpServerUtility.Transfer should be used in the case where you actually want to transfer the processing of the current request to another page without updating the user browser.