Tuesday, April 22, 2008

Difference between Response.Redirect and Server.Transfer

This question was asked by a client "Difference between Response.Redirect and Server.Transfer"

I thought oh! so simple question is this and as obvious my answer was

Response.Redirect have a extra round trip to browser and Server.Transfer does not have a extra trip (As had gone through this difference a lots of time in the web and whenever I found on the same I found the answer as provided above)

Now I am bowled
Where would you use which one ?????

Offfff I never thought of this...........

So I have given a wrong answer... and result you must be sure about the Result.....

So I decided to get the bottom of this and found one more interesting thing::

Response.Redirect :: User is redirected to new URL and you needs to pass the values in query string but not the page state.
Server.Transfer :: You can pass the state of page to another page but use is not aware of transfer to new URL as in the address bar URL remains the same, so he can not add to bookmark. This means that things like relative links / image paths may not work if you transfer to a page from a different directory.

No comments: