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.