I am trying to create a legacy route to redirect old asp links to the new urls.
My route is as follows and it's the first route in the list:
routes.MapRoute(
"", // Route name
"{*path}", // URL with parameters
new { controller = "Legacey", action = "Legacey" },
new { path = @".*\.asp.*" });// Parameter defaults
The problem I have is IIS intercepts these and 404s them before they hit my route. I guess there's a setting in the web.config to tell IIS to stop doing this but I can't find it.
You could accomplish this through URL rewriting, as explained in this post
Just add something like this to your web.Config (replace Legacey/Legacey with the redirect URL for the asp pages):
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect ASP Files to new URL" stopProcessing="true">
<match url="*\.asp" />
<action type="Redirect" url="Legacey/Legacey" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
I haven't tested this, it's just what I've understood from that post.