|
Redirects (Response.Redirect vs Server.Transfer) |
|
|
|
Sunday, 05 November 2006 |
|
This article show the difference between using Response.Redirect and Server.Tranfer methods in Asp.NET 2.0.
Response.Redirect simply sends a message to the browser, telling it to move to another page. //Example: Response.Redirect("news.aspx"); //or Response.Redirect("http://www.dotnetspace.com/") Server.Transfer is similar in that it sends the user to another page: //Example: Server.Transfer("Test2.aspx"). However, the statement Server.Transfer has a number of distinct advantages and disadvantages: 1- Server.Transfer conserves server resources. 2- It works in the web server, not in the user browser. So, it transfers the request and makes your applications run faster. 3- You cant use Server.Transfer to send the user to an external site. 4- Server.Transfer maintains the original URL in the browser. (Can be confuse to debug) 5- The Server.Transfer method also has a second parameter—"preserveForm". If you set this to True, using a statement such as Server.Transfer("Test2.aspx", True), the existing query string and any form variables will still be available to the page you are transferring to.
|
|
Last Updated ( Wednesday, 15 November 2006 )
|