Analysis of the difference between Response.Redirect and Server.Transfer in asp.net
Source: Internet
Author: User
The Server.Transfer method transfers the execution process from the current ASPX file to another ASPX page on the same server. When Server.Transfer is invoked, the current ASPX page terminates execution, and the execution process is transferred to another ASPX page, but the new ASPX page still uses the reply stream created by the previous ASPX page.
If you use the Server.Transfer method to navigate between pages, the URL in the browser does not change, because the redirection is done entirely on the server side, and the browser has no idea that the server has performed a page transformation.
Response.Redirect is the first time the client requests the server to return status code 302 and a new URL, the client again request a new URL, the server returned to the new page, more than Server.Transfer one response.
In general, if you need to share data between two pages, and the amount of data is relatively large, with transfer will be more appropriate, in the second page can directly use the previous page of data,
eg
Transfertopage.aspx
Copy Code code as follows:
if (Context.Handler is transferfrompage)
{
Transferfrompage post= (transferfrompage) Context.Handler;
Startweekid=int32.parse (post. Ddlstartweek.selectedvalue);
Endweekid=int32.parse (post. Ddlendweek.selectedvalue);
}
A value that references the previous page control directly.
Redirect can pass some smaller string values.
Response.Redirect ("B.aspx?id=0&name=jeff");
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service