Thursday, March 22, 2012

Response.Redirect Vs Server.Transfer



Response.Redirect Vs Server.Transfer




Server.Transfer: Transferring to another page using Server.Transfer conserves server resources. The transfer takes place on the server instead of forcing the browser to redirect to a new page. This means fewer HTTP requests coming through and can make your applications run more efficiently. Server.Transfer maintains to original URL in the browser.

Note:Only data transferred to a second ASP page are the ASP built-in objects and the ASP Error object values from the first request. Any variables declared by the first ASP page are not available in the second ASP page.

Server.Transfer has several advantages over Response.Redirect:
1) Because it saves a round trip between the server and the browser it's faster and reduces the load on the Web server.
2) The Response querystring and form collections are preserved during the transfer. As a result, you don't need to worry about reposting form and querystring data to the new page.

However, Server.Transfer does have a few disadvantages:

1) You can only use Server.Transfer to redirect to a page on the same Web server.
2) You can't pass a querystring to the new page. (However, remember that the querystring passed to the page executing the transfer will automatically be passed along to the new page.) If you try to pass a querystring to the new page, you will trigger an ASP error.
3) The browser is never notified of the new page, which can cause problems with relative links in some cases.
Note: Please 3rd point to noted very carefully



No comments:

Post a Comment