Difficulty Ignoring Route In Asp.Net Mvc
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 s开发者_如何学编程uch 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
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(/.*)?"})
精彩评论