Why not Server.Transfer why only Response.Redirect
I am having 2 text boxes and a button and a Href tag to open a calendar when clicks on it. The same i have on another page
I write a code to transfer to a particular page as follows using Respose.Redirect
protected void Button1_Click3(object sender, EventArgs e)
{
Response.R开发者_运维百科edirect("Demo/Default.aspx");//Works fine
//Server.Tranfer("Demo/Default.aspx"); // Does not works
}
This works cleanly but if i use Sever.Tranfer on the second page i am unable to load the calendar control when user clicks on Href tag
http://www.developer.com/net/asp/article.php/3299641/ServerTransfer-Vs-ResponseRedirect.htm
Firstly, transferring to another page using Server.Transfer conserves server resources. Instead of telling the browser to redirect, it simply changes the "focus" on the Web server and transfers the request. This means you don't get quite as many HTTP requests coming through, which therefore eases the pressure on your Web server and makes your applications run faster.
But watch out: because the "transfer" process can work on only those sites running on the server, you can't use Server.Transfer to send the user to an external site. Only Response.Redirect can do that.
Secondly, Server.Transfer maintains the original URL in the browser. This can really help streamline data entry techniques, although it may make for confusion when debugging.
That's not all: The Server.Transfer method also has a second parameter—"preserveForm". If you set this to True, using a statement such as Server.Transfer("WebForm2.aspx", True), the existing query string and any form variables will still be available to the page you are transferring to.
For example, if your WebForm1.aspx has a TextBox control called TextBox1 and you transferred to WebForm2.aspx with the preserveForm parameter set to True, you'd be able to retrieve the value of the original page TextBox control by referencing Request.Form("TextBox1").
精彩评论