04 July 2014

Difference between Response.Redirect() and Server.Transfer()

Response.Redirect() is used to navigate the user request between multiple webservers
whereas Server.Transfer() is used to navigate the user request within the webserver.


Response.Redirect() will not hide the Destination url address.
Server.Transfer() will hide the destination url address


Viewstate and hiddenfields data is collapsed in both cases of redirect or transfer


If you are using Server.Transfer then you can directly access the values, controls and properties of the previous page which you can’t do with Response.Redirect, Instead you can use querystrings


Server.Transfer sends a request directly to the web server and the web server delivers the response to the browser. So it is faster since there is one less roundtrip. but again it all depends on your requirement.


Response.Redirect can be used for both .aspx and HTML pages whereas Server.Transfer can be used only for .aspx pages and is specific to ASP and ASP.NET.


Both Response.Redirect and Server.Transfer have the same syntax like:
Response.Redirect("login.aspx");
Server.Transfer("login.aspx");

No comments: