(I don\'t know whether should I also post this question to ServerFault, since it\'s about IIS configuration?)
In IIS7 we can tell a module to run for manage
You can use a wild card script mapping, but it's inefficient to use the managed handler to handle all requests. The static handler is much more efficient when it is appropriate.
Removing preCondition="managedHandler"
or adding <modules runAllManagedModulesForAllRequests="true">
should do it. The "Preconditions" section of this page has more information.
The problem is in request-processing order. IIS7 processes requests in order specified by Handlers configuration element of IIS. By default Handlers element of the IIS configuration contains
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
at the end of the handlers. Therefore all request that not match any previously specified handler, will be processed by this handler (including folder request too).
You can remove all default handlers by using clear element in handlers configuration and specify your own request processing order.
I recommend to copy default IIS handlers configuration (C:\Windows\System32\inetsrv\config\applicationHost.config) to your web config without StaticFile handler at the end.
Then you should add specific static content handler for each static content type (jpg, gif, js, css).
<add name="StaticFile-swf" path="*.swf" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFile-png" path="*.png" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFile-gif" path="*.gif" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFile-jpg" path="*.jpg" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFile-css" path="*.css" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFile-js" path="*.js" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
and manged handler (PageHandlerFactory) for folder requests after that.
<add name="PageHandlerFactory-Folders" path="*" verb="*" type="System.Web.UI.PageHandlerFactory" modules="ManagedPipelineHandler" resourceType="Unspecified" requireAccess="Read" allowPathInfo="false" preCondition="integratedMode" />
At the end you should also add StaticFile handler.
Here is an example.