IgnoreRoute doesn't seem to work in my mixed MVC and ASP.NET application

391 views Asked by At

I am routing existing aspx files to a mvc controller to test things out, I wanted to also have a way to ignore the routing using IgnoreRoute, then I can just comment in or out that one line to switch between the aspx and MVC versions. e.g. a/b/mypage.aspx routed to controller = Billy, action = Index.

Here's what I tried where the MapRoute should have no effect because of a previous IgnoreRoute call:

RouteTable.Routes.RouteExistingFiles = true;

RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
RouteTable.Routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");

RouteTable.Routes.MapRoute(
    "Mine", // Route name
    "a/b/{c}", // URL with parameters
    new { controller = "Billy", action = "Index", id = "" },
    new { c = "(mypage\\.aspx)" }
    );

Here's my understanding of what should happen...
RouteExistingFiles is so that the aspx file that does exist will be considered for routing.
axd files will not be routed
aspx files will not be routed
the map route should have no effect as mypage.aspx should be ignored by the previous IgnoreRoute line.

The problem is the IgnoreRoute for the aspx doesn't seem to change anything, the MapRoute still happens.

Any help appreciated.

0

There are 0 answers