How can I add a route to the RouteConfig.cs file in an ASP.NET MVC 4 app to perform a permanent 301 redirect to another route?
I would like certain different routes to point at the same controller action - it seems a 301 would be best practice for this, specially for SEO?
Thanks.
You have to use RedirectPermanent, here's an example:
public class RedirectController : Controller
{
public ActionResult News()
{
// your code
return RedirectPermanent("/News");
}
}
in the global asax:
routes.MapRoute(
name: "News old route",
url: "web/news/Default.aspx",
defaults: new { controller = "Redirect", action = "News" }
);