Wednesday, September 28, 2011

Server.Transfer vs. Response.Redirect

Server.Transfer and Response.Redirect might seem like duplicates in ASP.NET but both are very different beasts. The fundamental difference between them is quiet easy to understand.



Fundamental Difference
Reponse.Redirect will forward the new url request to the end user browser as a 302 moved http response
Server.Transfer will continue the server side processing with a new aspx page

Implications
Intuitive with Respose.Redirect:
  • take longer due to a roundtrip (server - browser - server)
  • The address in the users browser address bar is changed
  • You can redirect to offsite pages
  • You can redirect to standard html pages
Additionally with Server.Transfer you can access properties of the aspx page that transfered the control whereas with Response.Redirect all the server side data objects are released (you can use session variable etc to store / retrieve and share data between pages obviously). 

Enjoy!

1 comment:

  1. Its really to good to see this article get more about this here http://www.vishalpatwardhan.com/2012/02/difference-between-servertransfers-and.html

    ReplyDelete