Monday, September 2, 2013

What is the difference between Server.Transfer() and Response.Redirect()?

In ASP.Net, both "Server" and "Response" are objects of ASP.Net. Server.Transfer() and Response.Redirect() both are used to transfer a user from one page to another page. But there are some significant dissimilarities between both the objects which are as follow:

 1.Response.Redirect() is used to redirect the user’s browser to another page or site, update the address bar and add it to the browser history. On your browser you can click back whereas Server.Transfer() does not change the address bar, we cannot hit back. You should use Server.Transfer() when you don’t want the user to see where he is going, mostly on a "loading" type page.

 2.Response.Redirect() redirects the request to some plain HTML pages on our server or to some other web server while Server.Transfer() transfers current page request to another .aspx page on the same server.

 3.Response.Redirect() performs additional round trip back to the client where the client’s browser is redirected to the new page. On the other hand, Server.Transfer() preserves server resources and avoids the unnecessary round-trip to the server so this provides a faster response with a little less overhead on the server.

 4.Response.Redirect() doesn’t preserve Query String and Form Variables from the original request while Server.Transfer() reserves Query String and Form Variables (optionally).

 5.Response.Redirect() enables to see the new redirected URL where it is redirected in the browser (and be able to bookmark it if it’s necessary). The user’s browser history list is updated to reflect the new address whereas Server.Transfer() doesn’t show the real URL where it redirects the request in the users Web Browser.

 6.Response.Redirect() simply sends a message down to the (HTTP 302) browser however, Server.Transfer() happens without the browser knowing anything, the browser request a page, but the server returns the content of another.

 I hope this article will be helpful for you!

1 comment:

  1. Great beat ! I would like to apprentice whilst you amend your site, how
    can i subscribe for a blog website? The account aided me
    a appropriate deal. I had been a little bit acquainted of this your broadcast
    provided vivid clear concept

    Feel free to visit my web page; minecraft games

    ReplyDelete