CODEDIGEST
Home » FAQs
Search
 

Technologies
 

What is the difference between Response.Redirect() and Server.Transfer() in ASP.Net ?
Submitted By Bala Murugan
On 2/28/2010 7:47:44 AM
Tags: Interview Questions,ASP.Net  

What is the difference between Response.Redirect and Server.Transfer in ASP.Net?

Response.Redirect() vs Server.Transfer()

 

In simple terms, both methods can be used to pass the users to a destination page.

 

We will see the difference between the two below,

 

Response.Redirect
1. It does a round trip to the client before reaching the destination page. i.e. when we redirect from source.aspx to destination.aspx, a round trip will happen to the client by updating the address bar and history of the browser and the destination.aspx page is loaded through a new request(second request) to the server.
2. You can pass data or values to the destination page through Query String.

 

Server.Transfer
1. It does not do a roundtrip to the client but the control to the destination page will be reached from the server itself. i.e. the destination.aspx will be loaded from the server without a second request. Thus, it will not update the address bar and history of the browser. The address bar will still show the source.aspx eventhough destination.aspx is loaded. Since, the destination.aspx is loaded from the server, it is a single request from source.aspx to destination.aspx.
2. Since it is a single request, you can use HttpContext object to pass values.
Read Pass Value to Destination Page When Using Server.Transfer to know more.
3. Since, the browser will not update the address bar, users will not be able to bookmark the destination page.

 

Hope this helps!

 

 

Recent FAQs
  • View All FAQs..