How IIS handles incoming requests

Description
Summary

Description of how web requests are processed by the IIS.

Description
Overview
When a request is received a worker process is initiated and it moves step-by-step until completion according a well-defined pipeline:
On each step an event is raised:
  1. BEGIN_REQUEST
  2. AUTHENTICATE_REQUEST
  3. AUTHORIZE_REQUEST
  4. RESOLVE_REQUEST_CACHE
  5. MAP_REQUEST_HANDLER
  6. ACQUIRE_REQUEST_STATE
  7. PRE_EXECUTE_REQUEST_HANDLER
  8. EXECUTE_REQUEST_HANDLER
  9. RELEASE_REQUEST_STATE
  10. UPDATE_REQUEST_CACHE
  11. LOG_REQUEST
  12. END_REQUEST

Users can register custom code to handle one or more events in the pipeline – referred to as module.
The EXECUTE_REQUEST_HANDLER event/task that is reserved for a special module – referred to as handler: The handler’s unique job is to retrieve the resource that is requested in the URL.

All the resources served by IIS are mapped to an handler in configuration.
If the configuration mapping does not exist, the requests for the resource will receive a 404 HTTP status.

How IIS works

The IIS worker process executes according two distint modes:

Classic Mode (IIS 6.0 and previous versions)

The classic mode is characterized by:

  • The ASP.NET pipeline (BeginRequest, AuthenticateRequest,…, EndRequest) runs entirely within the IIS pipeline’s EXECUTE_REQUEST_HANDLER event: ASP.NET pipeline runs within the main IIS pipeline;
  • IIS only works with ISAPI extensions and ISAPI filters directly.
Integrated Mode (IIS vs 7.x and later versions)

The integrated mode is characterized by:

  • All the requests are handled through a unified pipeline for IIS and is tightly integrated with ASP.NET and therefore IIS pipeline is the same as ASP.NET request pipeline;
  • ASP.NET modules behave as an ISAPI filter and ASP.NET handlers behaves as an ISAPI extension;
  • Managed and native modules can be registered for any of the events in the IIS pipeline regardless of whether or not the original request is an ASP.NET request

 

Note

The article How IIS handles incoming ASP.NET requests describes:

  • The ASP.NET pipeline step by step;
  • How to implement modules;
  • How to implement handlers

References

[1] IIS 7.0, ASP.NET, PIPELINES, MODULES, HANDLERS, AND PRECONDITIONS