tags:

views:

3142

answers:

3

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 ;))
A: 

You can try use custom errors to do this. Go into Custom Errors in you Website properties and set the 404 to point to a URL in your site. Like /404.aspx is that exists.

With aspnet_isapi, you want to use a HttpModule to handle your wildcards. like http://urlrewriter.net/

WebDude
A: 

You can't use wilcard mapping without using ASP.net Routing or URLrewriting or some url mapping mechanism.

If you want to do 404, you have to configure it in web.config -> Custom errors.
Then you can redirect to other pages if you want.

New in 3.5 SP1, you set the RedirectMode to "responseRewrite" to avoid a redirect to a custom error page and leave the URL in the browser untouched.

Other way to do it, will be catching the error in global.aspx, and redirecting. Please comment on the answer if you need further instructions.

Eduardo Molteni
+4  A: 

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

Christopher_G_Lewis