Possible Duplicates:
Response.Redirect vs. Server.Transfer
Server.Transfer Vs. Response.Redirect
What is the difference between response.redirect and server.transfer?
Only one difference i know is: In response.redirect the browser url changes to targeted page as well as in server.transfer the url remains same!
any other difference?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Response.Redirect should be used when:
-
we want to redirect the request to some plain HTML pages on our
server or to some other web server -
we don’t care about causing additional roundtrips to the server on
each request -
we do not need to preserve Query String and Form Variables from the
original request -
we want our users to be able to see the new redirected URL where he
is redirected in his browser (and be able to bookmark it if its
necessary)
Server.Transfer should be used when:
- we want to transfer current page request to another .aspx page on the same server
-
we want to preserve server resources and avoid the unnecessary
roundtrips to the server - we want to preserve Query String and Form Variables (optionally)
-
we don’t need to show the real URL where we redirected the request in
the users Web Browser
Method 2
Response.Redirect() sends a redirection header to the client, and the client itself requests the new page.
Server.Transfer() only stops rendering the current page and starts rendering another one. The client is none the wiser.
That’s why Server.Transfer() cannot be used to redirect to pages served by another server.
Method 3
Server.Transfer is more efficient because with Response.Redirect you tell the browser to make another request (another network roundtrip) whil Server.Transfer is “server-internal”…
Method 4
The Form data is transferred on Server.Transfer, but not on Response.Redirect, one other difference.
Also, if not mistaken, Server.Transfer works on the same server, not cross-server pages.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0