ASP. NET MVC3 permanent redirection method

Source: Internet
Author: User

Use ASP. NET and friends who like to follow up new technologies may already know that in ASP. added Response. NET 4.0. the RedirectPermanent () method is used to implement permanent redirection. The function of the method is clearly explained in the comment: execute the permanent redirection from the requested URL to the specified URL, and provides options for response completion.

In the ASP. net mvc 3 project, we can use the following method to achieve permanent redirection as needed:

The code is as follows: Copy code
Public ActionResult Index ()
{
Return RedirectPermanent ("Contact ");
Return RedirectToActionPermanent ("Contact ");
Return RedirectToRoutePermanent ("Contact ");

} In the past, we could set the status code in the HTTP data stream returned by the server. For example, if the status code is 301, it indicates permanent redirection. ASP. NET 4.0. NET Web Forms project and ASP. in the. net mvc project, we can easily implement permanent URL redirection.

This article briefly introduces the permanent redirection method in ASP. NET 4.0 MVC 3, and realizes that the code in ASP. NET is becoming more and more concise, which improves our efficiency.

 

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.