Server.Transfer Vs. Response.Redirect


This article tries to get difference between Server.Transfer() and Response.Redirect().

Server.Transfer Vs. Response.Redirect



We all uses Server.Transfer() and Response.Redirect() interchangeably. But what is the difference between two methods. Which one to use over other? We are just trying to get the advantages and disadvantages of both. So read down the article to get grasp of knowledge.

[1] Server.Transfer: Redirection to another URL is performed on server side. Transfer happens on server side and hence consume more resources on server side.

Response.Redirect: Requires a round trip to the browser running on user's computer. And then navigate to the URL specified. It increase overload on server by increasing requests to the server.

For Example:
You can understand it as your Web Application is running on the server, and then it comes to line Response.Redirect().This line tells the browser to make request to another page. So this is round trip to the browser.
While in case of Server.Transfer() page transfers directly to the URL specified without going to the browser.

[2] Server.Transfer: Maintains the original URL in the browser. So sometimes if user refresh page it makes confusion or error.

Response.Redirect: URL changes as the target URL specified.

[3] Server.Transfer: Method has a second parameter - bool preserveForm. If you set this to True, using a statement such as Server.Transfer("~/Target.aspx", True), the existing query string and any form collections will still be available to the transfering target page.

Response.Redirect: Method has a second parameter - bool endResponse. If you set this to True, using a statement such as Response.Redirect("~/Target.aspx", True), the execution of the current page terminates.

For Example:
If Source.aspx has a TextBox control called txtSource and you transferred to Target.aspx with the preserveForm parameter set to True, you will be able to retrieve the value of the original page(Source.aspx) TextBox control by referencing Request.Form("txtSource").

[4] Server.Transfer: Method cannot redirect to a different server itself.

Response.Redirect: Method can redirect to a different server also.


Related Articles

More articles: Respone redirect Server Transfer

Comments

Author: siva21 May 2010 Member Level: Gold   Points : 1

hai vikram,
its really good .and it is very help ful for me .really congrats to posting this one
thanks and regards
siva

Author: Vikram Singh Saini21 May 2010 Member Level: Gold   Points : 1

Hello Siva,

Thanks for appreciating the work. It would inspire me to share my knowledge with you members.

Regards,
Vikram Singh Saini

Author: Raju Melveetilpurayil21 May 2010 Member Level: Gold   Points : 1

ie Server.Transfer is better to use page transfers in same servers and if we want to redirect to any other location use Response.Redirect. but i u Response.Redirect for all pages to transfer page request.

thank you for a good article.
keep posting.

Author: surender15 Jun 2010 Member Level: Silver   Points : 0

nice posting

Author: saravanan15 Jun 2010 Member Level: Gold   Points : 0

Nice Explanation!!!!!



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: