Differences between server. Transfer and response. Redirect

Source: Internet
Author: User

1. server. Transfer

This API transfers the control of processing from one page to another. The information stored by the internal control (such as request and session) of the transfer project remains unchanged. Therefore, you can jump from page a to page B without losing the information on page.

2. response. Redirect

Send an HTTP Response to the client browser, telling the client which page to jump to, and the client sends a jump request to the server. Using this method, the data of the internal control cannot be saved. Page a jumps to page B, and page B cannot access the data submitted by form in.

The comparison is as follows:

Server. Transfer redirects the user to another page using the server method, response. Redirect redirects the user from the browser to another page,

The advantage of server. transfer is to pass the page parameters to the specified page. The server only transmits the context to another page. You can share the upstream and downstream information between pages without using a large number of HTTP requests temporarily. This reduces the number of requests sent from the client to the server, reduces the pressure on the server, and enables your server to run faster, response. redirect requires an additional round-trip process, which affects performance.

After server. Transfer jumps to the page, the URL address displayed by the browser does not change, and the user's browser does not know that the URL is being transferred. Therefore, historical records are not updated. If the user renews the page, unexpected results are generated.

Note that server. Transfer can only be accessed from the same site on the same server. It cannot be redirected to. asp or. asmx pages. Only response. Redirect can be used.

When programming, we try to use server. transfer when redirecting inside the website system, and response. Redirect can be used for targeting external addresses.

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.