IIS - Wildcard Mapping - Asked By Stuart Neilson on 07-Jan-10 01:27 PM

HI forum,

I am fond of my hair so would like to keep what I have left. I am trying to get a custom 404 error message when someone puts in http://site.com/foo. In other words no file extension.

I have the following environment.
Fully updated Windows 2003 running ASP.NET 3.5 website.
I have customErrors set in web.config for 404.
I have 404 error set up to same url in website properties for 404 errors.

Things work fine when a file extension that is handled by ASPNET_ISAPI is hit but not for a file with no extension.

I thought wildcard mapping would do it so I set it to map to ASPNET_ISAPI. I did an IISRESET and went back into the properties and the mapping that I just inserted was gone! WTF?

Any help would be appreciated as I would like to capture as many fat fingered visitors as possible.



Did you mean to see the error? - [)ia6l0 iii replied to Stuart Neilson on 07-Jan-10 02:35 PM

 and do you mean that you are seeing some default page when you hit only the folder names?

If yes, then remove the default documents for the folder. Also , do this:
  • Right-click on the virtual directory - Choose properties
  • Choose Custom Errors - 404 Http error - Click Edit properties.
  • In the Error mapping, what do you see? Is it mapped to some default document?

Wildcard Mapping - Stuart Neilson replied to [)ia6l0 iii on 07-Jan-10 05:33 PM

It displays the 404 error that is part of the browser. I am trying to capture ALL 404 errors and put them to a page like google does for instance.



`Wildcard Mapping - mv ark replied to Stuart Neilson on 08-Jan-10 02:45 AM

When you request extensionless URL, you get HTTP 404 page. This means IIS receives the request and it serves the page configured for HTTP 404. Generally this is a 404.html file that resides in IIS directory. IIS does not send the request to ASP.NET handler and thus you cannot intercept 404 requests. So, if you can forward all HTTP 404 to ASP.NET, you can serve such extensionless URL. In order to forward HTTP 404 to ASP.NET ISAPI, all you need to do is configure IIS to redirect to some .aspx extension when a missing extensionless url is hit.
For help on configuring IIS to redirect to a specified .aspx page, check this article - http://www.codeproject.com/KB/aspnet/extensionless.aspx

Alternatively, you can also try Google Webmaster Tools 404 widget - http://googlewebmastercentral.blogspot.com/2008/08/make-your-404-pages-more-useful.html

That does not work. I tried. - Stuart Neilson replied to mv ark on 08-Jan-10 12:00 PM
That does not work. I tried everything there.

This is what I need but for IIS6.

Also, can anyone tell me why when I put in ASPNET_ISAPI as a wildcard and do an IISRESET and then go back into properties it is wiped out?!?!
Problem fixed - Stuart Neilson replied to mv ark on 08-Jan-10 12:45 PM
Well I have to blame the network admin on this one. He changed the IP to the website and did not tell me. I have been making changes to a site that has never been hit. I discovered this after I went to view the logs for the site I have been changing all this time and saw there was no traffic...!?!?!

I have not fully figured out what works and what does not yet but here is what I have.

In web.config I have 404 customError pointing to a page.
In IIS6 Properties|Home Directory|Configuration added a wildcard and pointed it to ASPNET_ISAPI.dll

Thanks to those that tried to help.

I am off to comb my hair lovingly.