We used to use ISAPI Re-Write (Infact its still on our server) although it doesnt work with ASP.Net MVC (Somthing to do with 'euxd' get param).
We need a relaiable way to implement simple 301 redirects, when we change the site structure, upload a new site etc. Any suggestions?
Ok, it I wanted to redirect /SomeFolder/SomePage.HTML?Param1=X to /NewPage/X
How can we do that?
301 is an HTTP status code sent by a web server to a browser. A 301 signals a permanent redirect from one URL to another, meaning all users that request an old URL will be automatically sent to a new URL.
The HyperText Transfer Protocol (HTTP) 301 Moved Permanently redirect status response code indicates that the requested resource has been definitively moved to the URL given by the Location headers. A browser redirects to the new URL and search engines update their links to the resource.
RedirectToAction(String, String, RouteValueDictionary) Redirects to the specified action using the action name, controller name, and route values.
In MVC 3 there are three new redirect methods that can be used in controllers to redirect permanently (produce a 301); as opposed to the 302s (temporary redirect) produced by the MVC 2 redirects.
public ActionResult OldAction() { return RedirectPermanent(urlname); }
There is a great tutorial in the Controllers section of these walkthroughs on PluralSight.
If you are using IIS7, I would recommend using the official IIS7 URL Rewrite module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With