Discussion on ASP.net webpage redirection Methods

Source: Internet
Author: User
There are three methods for page redirection:

1. response. Redirect ("url ");

2. server. Transfer ("url ");

3. server. excute ("url ")

Server. Transfer ("url") has three advantages compared with the most common response. redirdbms ("url ").

Advantages:

1. It is directly redirected on the server side and does not need to communicate with the browser before redirecting like response. Redirect, which is highly efficient.

 

2. It can pass the submission value of the previous page. For example, if the value of page a is submitted to page B, and the value of page B is transferred to Page C, Page C can also receive the value submitted by page.

3. You can hide URLs.

Disadvantages)

You cannot refresh the page. For example, If logon information is submitted to page B on page A and transfer is sent to page a after page B is processed, page a cannot be refreshed, and the specified page does not expire. If pages A and B are not in the same directory, we will find more unexpected results. The images and hyperlinks with relative links have all changed, this is because page B reads the content of page a but outputs it as page B, so the path is changed.

There are four page navigation methods in Asp.net. How do I select one for your page?

· If you want users to decide when to convert a page and which page to go to, hyperlink is the most suitable.

 

· If you want to useProgramTo control the conversion target, but the conversion time is determined by the user. Use the web server's hyperlink control to dynamically set its navigateurl attribute.

· If you want to connect a user to resources on another server, use response. Redirect.

· Use response. Redirect to connect users to non-aspx resources, such as HTML pages.

· If you want to retain the query string as part of the URL, use response. Redirect.

· If you want to transfer the execution process to another ASPX page of the same web server, you should use server. transfer instead of response. redirect, because server. transfer can avoid unnecessary network communication to achieve better performance and browsing performance.

 

Reprinted from: http://www.fengfly.com/plus/view-80980-1.html

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.