2

I have a site built using asp.net mvc running on IIS 7 using integrated mode. I noticed when I type in mysite.com/test.html I get back The IControllerFactory did not return a controller for a controller named 'test.html'.

What I should have gotten was a 404 error and this should of been served by the IIS7 Static Handler.

Now what I am wondering, does the asp.net mvc handler serve everything? (css, images, zip archives) instead of the static file handler.

If it does then is there a way I can work around this so the Static handler will serve files with extensions. Otherwise this seems like a big performance issue.

Danny Tuppeny
  • 40,147
  • 24
  • 151
  • 275
Mike Geise
  • 825
  • 7
  • 15

1 Answers1

2

By default, ASP.NET MVC will handle all requests, since the routing is designed to handle any paths. You could specifically exclude certain paths by using the IgnoreRoute method, like this (in Global.asax):

public static void RegisterRoutes(RouteCollection routes)
{
    // This is already added by MVC
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    // Ignore any htm files
    routes.IgnoreRoute("{filename}.htm");

    // Other routes
    // ...
}

I suspect this will still result in requests going through ASP.NET (though I suspect they'll "fall through" quite quickly). If this is a problem, you could try changing the web.config settings to not pass the requests to ASP.NET at all:

<modules runAllManagedModulesForAllRequests="false" />

However you'll need to set up exactly which requests you want to go through ASP.NET.

Danny Tuppeny
  • 40,147
  • 24
  • 151
  • 275