Friday, 03 July 2009
DotNetSpace, Asp.net 2.0 tutorials and code examples. ajax, log4net...
Home arrow Articles arrow General Articles arrow Redirects (Response.Redirect vs Server.Transfer)
 
Main Menu
Home
Articles
News
Links
Search








BiraJones




Redirects (Response.Redirect vs Server.Transfer) Print E-mail
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 )
 
< Prev   Next >
Popular
Polls
-->*/?>

Which language will you choose for coding with Visual Studio .NET?
 
-->*/?>

Is ASP.NET better than Java / JSP frameworks?
 

© 2009 DotNetSpace
Joomla! is Free Software released under the GNU/GPL License.