I still remember the old days when I first learned ASP.NET 1.0. Like other newcomers, I used to search for the differences between Response.Redirect and Server.Transfer. I found answers claiming that Server.Transfer had been kept in ASP.NET for backward compatibility with ASP, so the recommendation was to use Response.Redirect, or that I should be using Server.Transfer for better performance!
The truth is that each method has a completely different and important use.
Response.Redirect: When you call this method, ASP.NET will issue HTTP headers that will instruct the browser to navigate to the new page and will stop processing any further ASP.NET instructions. The following code:
Response.Redirect("default2.aspx");
throw new Exception("This exception will not be executed!");
will redirect to default2.aspx and will not execute the next line. It will issue an HTTP header instruction to the browser as follows:
Location: /default2.aspx
Then the browser will request the new page “default2.aspx”.
Server.Transfer: This method will transfer execution ON THE SERVER from the currently executing page to the new page “default2.aspx” without notifying the client (the browser) of this change. Also, it will stop executing any further instructions on the current page.
Server.Transfer("default2.aspx");
throw new Exception("This exception will not be executed!");