ASP. NET MVC && ASP page jump

Source: Internet
Author: User

1. Use of traditional Response.Redirect
For example
String url = "/account/create";
Response.Redirect (URL);

1.server.transfer Method:
Server.Transfer ("m2.aspx");//page steering (performed on server). The server stops parsing this page, saves the data before turning it, and then turns the page to m2.aspx and returns the M2.aspx page results to the browser.
2.server.execute Method:
Server.Execute ("m2.aspx"); After the server saves this page to the previous data, it turns the page to m2.aspx execution, and then returns to this page to continue execution. Merge the three results back to the browser.
The above is the server-side page steering so the browser does not appear the page change record (the displayed address will not change). Therefore, if the user refreshes this page, there may be some other unexpected situation. This type of page turns and can accomplish some other functions, such as accessing the server-side controls on the previous page.
3.response.redirect:
When the browser requests an ASPX page, it encounters the redirect (URL) method, which is equivalent to telling the browser that you need to access a page before the browser sends a request to the server to that page. Relocation is performed through the browser, which generates additional round trips between the server and the browser. In a situation where the network is not in good condition, two requests can greatly reduce the response speed of the application, and even occupy the extra bandwidth.
Summary, in the case of better network status, Redirect (URL) method is the most efficient!! Server.Transfer method and Server.Execute method are the most flexible!! The Server.Execute method consumes the most resources.



2. Use MVC's new Redirecttoaction ("Action name", "Controller name");
Return redirecttoaction ("Index", "Home");//Jump to homepage.
The first parameter is the name of the action, and the second argument is the name of the Director Controller, and the method returns a ActionResult. That is, return to the view.

ASP. NET MVC && ASP page jump

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.