asp.net jump Page Three ways to compare _ practical skills

Source: Internet
Author: User

1, Response.Redirect This jump page method jump speed is not quick, because it wants to walk 2 back and forth (2 times postback), but he can jump to any page, no Site page restrictions (that is, can be jumped from Yahoo to Sina), at the same time can not skip login protection.
But slow speed is its biggest flaw!redirect jump mechanism: First is sends an HTTP request to the client, the notification needs to jump to the new page, then the client sends the jump request to the server side. Note that all the data information stored in the internal space after the jump is lost, so you need to use the session.
2, Server.Transfer fast, only need one postback, but .... He must be under the same site as it is a method of the server. In addition, he can skip login protection. You can write a small program to try: Design a page to page two of the jump, but to enter the page two need to login, form certification, but if the jump statement using transfer words, it will not pop-up login page. The redirection request of this method occurs on the server side, so the URL address of the browser still retains the address of the original page!
3, Sever.execute This method is mainly used in the page design above, and he must be to jump the same site under the page. This method is needed to insert the output of one page into another ASPX page, mostly in a table where one page is similar to nesting in another.
Summarize:
When you need to jump the user to a page on another server, use the redirect
When you need to jump the user to a non-ASPX page, such as HTML, use redirect
When you need to keep the query string as part of the URL to the server, because the other 2 methods can not do 2 times postback, the data back to the server, using redirect
Requires a transition between ASPX pages (not involving logins), using transfer
Use the Execute method when you need to insert the output of an ASPX page into another ASPX page.
Of course, forget there is a hyperlink! Of course, there's no need to talk too much about it. He is using hyperlinks when they need a user to decide when to jump the page.
Incidentally, how to use the Redirect method to use Chinese characters in the query string, because it is often garbled, because the URL does not support Chinese characters. This time you need to convert:
The following is a reference fragment:
String Message =server.urlencode ("Welcome to the racing column");
Convert first, then use query string
The following is a reference fragment:
Response.Redirect ("webform2.aspx?msg=" +message);

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.