Differences 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 called, the current ASPX page is terminated and the execution process is transferred to another ASPX page. However, the new ASPX page still uses the response stream created on the previous ASPX page.
If you use the Server. Transfer method to implement navigation between pages, the URL in the browser will not change because the redirection is completely performed on the Server side, and the browser does not know that the Server has executed 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 requests a new URL again, and the Server returns a new page, which is one more Response than Server. Transfer.


Generally, if you need to share data between two pages and the data volume is large, it is more appropriate to use transfer. On the second page, you can directly use the data on the previous page,

Eg:
TransferToPage. aspx
Copy codeThe Code is as follows:
If (Context. Handler is TransferFromPage)
{
TransferFromPage post = (TransferFromPage) Context. Handler;
StartWeekID = Int32.Parse (post. DdlStartWeek. SelectedValue );
EndWeekID = Int32.Parse (post. DdlEndWeek. SelectedValue );
}

Directly reference the value of the control on the previous page.
Redirect can pass some smaller string values.
Response. Redirect ("B. aspx? Id = 0 & name = Jeff ");

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.