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?
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?
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 fromapplicationHost.config
for all the different page handlers a.aspx
page can have (I've removed some attributes to keep things concise):When a
.aspx
request is passed through the IIS pipeline only the handler that matches thepreCondition
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:
If
Default.aspx
was requested then the handler chosen to process this request would be:There is a great article that explains
preConditions
in much more detail here: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.