mathieu
mathieu

Reputation: 31192

IIS Wildcard Mapping not working for ASP.NET

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 :

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:

Upvotes: 4

Views: 6528

Answers (3)

Christopher G. Lewis
Christopher G. Lewis

Reputation: 4835

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

Upvotes: 4

Eduardo Molteni
Eduardo Molteni

Reputation: 39453

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.

Upvotes: 0

WebDude
WebDude

Reputation: 6215

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/

Upvotes: 0

Related Questions