Concept of Server.Transfer and Response.Redirect
Basically both of these are used when we want to make switch between two pages.
1) Server.Transfer :
This method is used to transfer user from one page to other page without generating a new HTTP request . Thus this will lead to lesser roundtrip time (RoundTrip time is the time for the request sent and response received), because in this case user is moved to the next page at server side rather than making request first at client side and sending this request again to server to get the new page as is done in case of Reponse.Redirect .
Working of Server.transer is demonstrated in the diagram above
2) Response.Redirect :Response.redirect sends HTTP code 302 down to the users browser along with the url location of the requested page . HTTP code 302 actually means 'The requested resource resides under a different URI' . Thus simply , it can be said that Reponse.Redirect initiates another request to the server , but this is not the case with Server.Transfer because in that case , the original request is simply rewritten and is transferred to some other page on the server.
Working of Response.Redirect is demonstrated in the diagram above
Differences among the both :
Response.Redirect should be used when:
we need to redirect the request 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 need our users to be able to see the new redirected URL where he is redirected in his browser.
Server.Transfer should be used when:
we need to transfer current page request to another page on the same server.
we need to preserve server resources and avoid the unnecessary roundtrips to the server.
we need 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.