Why Wildcard application mapping is not catching 404s

I recently did a brain-dump about IIS6 Request Processing and detailed how Wildcard application mappings fit in. Let's apply that info to the following question...

Question:

Hi David,

Sorry to bother through here but I couldn't find an online answer... or something may be wrong with my VPC installation... not sure. Thing is I've setup in IIS6 a wildcard entry to aspnet_isapi.dll in order to get all request through ASP.NET (I made sure the "Verify that file exists" is not checked) and I still can't get the requests to my ASP.NET app. I'm getting IIS 404 error for non-existent URLs... (that I would like to handle in my ASP.NET app).

Any idea of where else to look for this?

Thanks!!!

Answer:

First, you want to read this blog entry on how IIS6 Request Processing works and how wildcard application mapping fits into the overall picture.

Wildcard application mapping is definitely able to catch requests for non-existent URLs. I confirmed using my test ISAPI DLL, configured as a wildcard application mapping, that it DOES get invoked with the correct ServerVariables for the non-existent URL when "Verify that file exists" is unchecked. This tells me that ASPNET_ISAPI.DLL definitely gets invoked for those requests.

You are claiming that you:

  1. See IIS 404 errors, which suggest that ASPNET_ISAPI.DLL did not get invoked (ASP.Net does not read nor send IIS custom errors)
  2. Correctly configured ASPNET_ISAPI.DLL to act as a wildcard application mapping applicable for the non-existent URL.

Unfortunately, those two claims directly contract each other, and combined with what I had earlier confirmed, I can only conclude that one of your two claims is mistaken. Either you did not see the IIS 404 custom error response, or you did not configure ASPNET_ISAPI.DLL to act as a wildcard application mapping applicable for the non-existent URL.

Now, since the former is very hard to mistake (IIS and ASP.Net custom error responses are very different), I suspect that some form of the latter is going on. Here is one possible explanation.

The IIS configuration for wildcard application mapping is inheritable from the parent to the child, unless overriden. This means that if you change wildcard application mapping at the global level, thenĀ it will apply to all applications on the server UNLESS that application has a local override.

ASP.Net constantly tweaks the property containing wildcard application mappings to make them local-override, so I think that you have a local-override applicable to the non-existent URL that does NOT match your perceived setting of wildcard application mapping.

The fix is easy - either:

  1. Modify the local-override to include your wildcard application mapping.
  2. Delete the local-override so that it inherits from your perceived setting.

Another possibility that you want to consider is how Default Document resoluotion can be affected by a wildcard application mapping. Read the following blog entry for more details and explanations.

Now, if it still does not work after this (so you are sure that ASPNET_ISAPI.DLL is getting invoked to handle the non-existent URLs), then the issue is really an ASP.Net question and no longer an IIS6/wildcard application mapping question. Unfortunately, I am not an ASP.Net expert, so I do not know why ASP.Net is not invoking the applicable HttpHandler, HttpModule, or ASP.Net app to handle the non-existent URL. You will probably get better support for this question at the ASP.Net Forums on www.asp.net .

Good Luck.

//David