问题
The following exception is being thrown after an IgnoreRoute method call:
The controller for path '/anything.php' was not found or does not implement IController.
However, I have the following method in my MvcApplication class:
public static void RegisterRoutes(RouteCollection routes)
{
routes.RouteExistingFiles = false;
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*php}", new { php = @"(/?.*/)*\.php$" });
// Some calls to routes.MapRoute occur here.
}
I'm not really sure why the exception is being thrown if the Mvc website is set up to ignore such routes. Also, I'm testing the site by hitting F5 in Visual Studio and then replacing http://localhost:12345/ by http://localhost:12345/anything.php. Any help is much appreciated!
Thanks,
Andrew
回答1:
Have you checked your regular expression to make sure it's .NET compatible?
Try replacing your regex with this regex:
routes.IgnoreRoute("{*allphp}", new {allphp=@".*\.php(/.*)?"})
来源:https://stackoverflow.com/questions/6351727/difficulty-ignoring-route-in-asp-net-mvc