Wednesday, 16 January 2013

Difference Between Server.Transfer vs Response.Redirect

There is a common question for developers in interview board that "What is the difference between Response.Redirect and Server.Transfer". In a common term we can use both to redirect the user from source page to destination page. But there are some differences in between Response.Redirect and Server.Transfer, which i want to share with you.

1. A round trip occurs to the client before loading the destination page, which means after redirecting a page from source page to destination page a round trip occur into the client to update the address bar and history of the client browser. And also the destination page will be loaded by initiating a new request which is the 2nd request to the server.
2. To pass data in this mechanism you can easily use Query String or Session value.

1.It is a single request from source page to destination page. The destination.aspx will be loaded from the server without a second request. Means it will not update the address bar and history of the browser.
2. You will get better performance.
3. You cannot use Query String.
4. To pass data between souce.aspx page to destination.aspx by using HttpContext object. Click here to use HttpContext object.
5. You can also use session object to transfer data.
6. Users can not bookmark the destination.aspx page.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.