In ASP.NET MVC routing, if you want to support legacy routes, you can add something like this:
routes.MapRoute("SiteDefault", "Default.aspx",
new { controller = "Home", action = "Index" });
That's great, but when I use @Url.Action
to generate link for Home controller Index action as following:
<a href="@Url.Action("Index", "Home")">Home</a>
Url generated is /Default.aspx
and not /Home
.
How can I get helper to generate /Home
and still support route mapping for /Default.aspx
?
I know that I can create physical Default.aspx
file and have permanent redirect inside it, but I am trying to avoid adding unnecessary files.
Or is there a way to write Extension for UrlHelper
that would do this?