Users frequently configure ISAPIs like ASPNET_ISAPI.DLL as a wildcard application mapping on IIS6 to route all requests into ASP.Net for processing (for example, to apply ASP.Net Forms authentication onto non-ASP.Net resources like a JPG or HTML).
However, as soon as they do this, they may notice that some IIS features such as default document resolution, application mapping resolution, and directory browsing stop working. Why?
Is this a problem with IIS6, a bug in the ISAPI configured as the wildcard application mapping, or maybe it is by-design?
On IIS6 I have configured a wildcard application mapping, but now when I just browse to a URL or an IP without specifying a document, it does not add the "default document" anymore. Is it a bug in IIS 6.0 ?
Does anyone know a workaround? Or does anyone have code to replace the "default document settings" in an isapifilter? I don't have any clue how to do that.Any help would be very much appreciated
Tiziana
This is definitely not a bug in IIS6, and depending on the ISAPI, it may not even be a bug... so let me explain what is going on here.
However, since almost all existing ISAPI DLLs are not written to function as a proper wildcard application mapping, I consider your observations to be "by-design" behavior. In particular, if you configure ASPNET_ISAPI.DLL from ASP.Net 1.0 or ASP.Net 1.1 to be a wildcard application mapping on IIS6, the behavior you observe is totally by-design.
In other words, just because you can configure something as a wildcard application mapping does not make it correct, even if some things appear to work.
At a high level, IIS goes through a straight forward process to determine which handler(s) should handle generating the response for a given request. Please read the IIS6 Request Processing Basics URL for details.
Now, suppose you configured ASPNET_ISAPI.DLL from ASP.Net 1.1 as a wildcard application mapping. What happens?
Well, according to the "IIS6 Request Processing Basics" URL, wildcard application mappings can intercept the determination of a request handler right at the beginning, so it can definitely step in before the Courtesy 302 Redirection or the DefaultDoc determination happens.
Now, the million dollar question:
What do you think happens if the wildcard application mapping returns "I AM handling the request" and short-circuits the rest of normal request processing?
Yup, you guessed it. Look at the havoc and weird behaviors that can happen with a misbehaving wildcard application mapping:
Clearly, like any ISAPI, a wildcard application mapping can prevent IIS from functioning properly to the user's usual expectations. Allowing ISAPI to have this power is by-design - an ISAPI controls exactly how the server behaves, for good and for bad. The ISAPI can certainly handle all those broken usage cases above, but it is up to the ISAPI to do so, not IIS, since it is supposed to "handle" the request.
Now, what is special about IIS6 is that it introduces the HSE_REQ_EXEC_URL ISAPI ServerSupportFunction call, which basically allows an ISAPI to return "I am NOT handling the request". This, in combination with wildcard application mapping's placement at the front of IIS determination of request handler, allows IIS to execute ISAPI DLLs for the side effect of "filtering a request" yet not own handling the request. Correspondingly, the end result is a lot nicer because IIS got to handle the request as it wanted; the ISAPI merely filtered the request for side effect.
This, in a nutshell, is how a ISAPI can function as a proper wildcard application mapping... and why existing ISAPIs cannot properly function as a wildcard application mapping. They do not call HSE_REQ_EXEC_URL.
Now, ASPNET_ISAPI.DLL of ASP.Net 2.0 is a different story. It does have functionality to call HSE_REQ_EXEC_URL, controllable via managed code. This allows managed code to filter yet not own handling the request, allowing for scenarios like ASP.Net Forms Auth applying to ASP pages... and that is a whole other topic on its own. :-)
//David