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.