ASP.Net Programming Question:
Download Questions PDF

What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?

ASP.Net Interview Question
ASP.Net Interview Question

Answers:

Answer #1
In earlier versions of IIS, if we wanted to send a user to a new Web page, the only option we had was Response.Redirect. While this method does accomplish our goal, it has several important drawbacks. The biggest problem is that this method causes each page to be treated as a separate transaction. Besides making it difficult to maintain your transactional integrity, Response.Redirect introduces some additional headaches. First, it prevents good encapsulation of code. Second, you lose access to all of the properties in the Request object. Sure, there are workarounds, but they're difficult. Finally, Response.Redirect necessitates a round trip to the client, which, on high-volume sites, causes scalability problems.
As you might suspect, Server.Transfer fixes all of these problems. It does this by performing the transfer on the server without requiring a roundtrip to the client.

Answer #2
Response.Redirect will be used if transfer bw websites
if transfer within a website we use server.transfer

Answer #3
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

Download ASP.Net Interview Questions And Answers PDF

Previous QuestionNext Question
What are ASP.NET Web Forms? How is this technology different than what is available though ASP?How can you provide an alternating color scheme in a Repeater control?