IIS Wildcard Mapping not working for ASP.NET

asp.netiis

I've set up wildcard mapping on IIS 6, by adding "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll", and ensured "Verify that file exists" is not checked :

  • on the "websites" directory in IIS
  • on the website

However, after a iisreset, when I go to http://myserver/something.gif, I still get IIS 404 error, not asp.net one.

Is there something I missed ?

Precisions:

  • this is not for using ASP.NET MVC
  • i'd rather not use iis 404 custom error pages, as I have a httpmodule for logging errors (this is a low traffic internal site, so wildcard mapping performance penalty is not a problem ;))

Best Answer

You need to add an HTTP Handler in your web config for gif files:

  <system.web>
    <httpHandlers>
      <add path="*.gif" verb="GET,HEAD" type="System.Web.StaticFileHandler" validate="true"/>
    </httpHandlers>
  </system.web>

That forces .Net to handle the file, then you'll get the .Net error.

Server Error in '/' Application.

The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /test.gif


Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433