4

Given multiple handler mappings are configured to handle a request, in IIS, what is the algorithm for determining which one is used to serve the response?

1 Answer 1

5

I am presuming you are asking about IIS7 Handler Mappings.

Hidden from view in IIS Manager there is a preCondition attribute for each handler mapping. For example here is an excerpt from applicationHost.config for all the different page handlers a .aspx page can have (I've removed some attributes to keep things concise):

<add name="PageHandlerFactory-ISAPI-4.0_32bit" path="*.aspx" 
     preCondition="classicMode,runtimeVersionv4.0,bitness32" />
<add name="PageHandlerFactory-ISAPI-4.0_64bit" path="*.aspx" 
     preCondition="classicMode,runtimeVersionv4.0,bitness64" />
<add name="PageHandlerFactory-Integrated-4.0" path="*.aspx" 
     preCondition="integratedMode,runtimeVersionv4.0" />
<add name="PageHandlerFactory-Integrated" path="*.aspx" 
     preCondition="integratedMode" />
<add name="PageHandlerFactory-ISAPI-2.0" path="*.aspx" 
     preCondition="classicMode,runtimeVersionv2.0,bitness32" />
<add name="PageHandlerFactory-ISAPI-2.0-64" path="*.aspx" 
     preCondition="classicMode,runtimeVersionv2.0,bitness64" />

When a .aspx request is passed through the IIS pipeline only the handler that matches the preCondition is used.

The preConditions generally map to the configuration of the application pool that the site or application runs in.

So if I had a site running in an application pool configured as:

.NET Framework Version [managedRuntimeVersion]     = v2.0
Enable 32-Bit Applications [enable32BitAppOnWin64] = True
Managed Pipeline Mode [managedPipelineMode]        = Classic

If Default.aspx was requested then the handler chosen to process this request would be:

PageHandlerFactory-ISAPI-2.0

There is a great article that explains preConditions in much more detail here:

Achtung! IIS7 Preconditions

I forgot to say that the order of the handler mappings is also a consideration, particularly for wildcard and extensionless mappings. The order of these can be viewed/changed in IIS Manager by opening the Handler Mappings feature for a site and then clicking on the View Ordered List link in the right hand Actions pane. In this view you can change the processing order of the handlers.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .