asp.net MVC3 301 Permanent REDIRECT Implementation program

Source: Internet
Author: User

Friends who use ASP.net and follow the new technology may already know that the Response.redirectpermanent () method has been added in ASP.net 4.0 to achieve permanent redirection, and the effect of the method is clearly explained in the annotation: execution from the requested URL to the specified A permanent redirection of URLs and provides options for completing the response.

In the ASP.net MVC 3 project, we can use the following notation to implement permanent redirection as needed:

The code is as follows Copy Code

Public ActionResult Index ()
{
Return redirectpermanent ("contact");
Return redirecttoactionpermanent ("contact");
Return redirecttoroutepermanent ("contact");
}

We used to be able to set the status code in the HTTP data stream returned by the server, such as specifying a status code of 301 for permanent redirection, and now in asp.net 4.0, asp.net Web forms projects and ASP.net MVC projects, we can easily implement URLs permanently redirect.

This article mainly introduces the ASP.net 4.0 MVC 3 in the permanent redirection, and realizes that the code in ASP.net is becoming more and more concise, improving our efficiency.

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.