Take the 2-minute tour ×

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("{*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!



share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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(/.*)?"})
share|improve this answer
Thanks for the reply, George! I'm now getting the error "File does not exist."... Is this supposed to happen? –  Andrew Jun 15 '11 at 1:28
@Andrew it happens if that file doesn't exist wherever you requested it. So if you don't have a anything.php in the root of your web folder, you'll get the 404 for that. Also recognize that you need to make sure IIS and ASP.NET handle php correctly (which will vary on your needs, and I'm not qualified to talk about running PHP side-by-side with ASP.NET MVC). –  George Stocker Jun 15 '11 at 1:39
Thanks again. I'll try to get the request stopped via IIS, if possible. The website is completely asp.net mvc, but it keeps getting these automated requests for php pages, probably by devious automated processes running on other servers. I just wanted to ignore the errors. Thanks! –  Andrew Jun 15 '11 at 1:47
add comment

Your Answer


