IIS 7.0 Application Life Cycle


The following tasks are performed by the HttpApplication class while the request is being processed. The events are useful for page developers who want to run code when key request pipeline events are raised. They are also useful if you are developing a custom module and you want the module to be invoked for all requests to the pipeline. Custom modules implement the IHttpModule interface. In Integrated mode in IIS 7.0, you must register event handlers in a module’s Init method.

  1. Validate the request, which examines the information sent by the browser and determines whether it contains potentially malicious markup. For more information, see ValidateRequest and Script Exploits Overview.
  2. Perform URL mapping, if any URLs have been configured in the UrlMappingsSection section of the Web.config file.
  3. Raise the BeginRequest event.
  4. Raise the AuthenticateRequest event.
  5. Raise the PostAuthenticateRequest event.
  6. Raise the AuthorizeRequest event.
  7. Raise the PostAuthorizeRequest event.
  8. Raise the ResolveRequestCache event.
  9. Raise the PostResolveRequestCache event.
  10. Raise the MapRequestHandler event. An appropriate handler is selected based on the file-name extension of the requested resource. The handler can be a native-code module such as the IIS 7.0 StaticFileModule or a managed-code module such as the PageHandlerFactory class (which handles .aspx files). 
  11. Raise the PostMapRequestHandler event.
  12. Raise the AcquireRequestState event.
  13. Raise the PostAcquireRequestState event.
  14. Raise the PreRequestHandlerExecute event.
  15. Call the ProcessRequest method (or the asynchronous version IHttpAsyncHandler.BeginProcessRequest) of the appropriate IHttpHandler class for the request. For example, if the request is for a page, the current page instance handles the request.
  16. Raise the PostRequestHandlerExecute event.
  17. Raise the ReleaseRequestState event.
  18. Raise the PostReleaseRequestState event.
  19. Perform response filtering if the Filter property is defined.
  20. Raise the UpdateRequestCache event.
  21. Raise the PostUpdateRequestCache event.
  22. Raise the LogRequest event.
  23. Raise the PostLogRequest event.
  24. Raise the EndRequest event.
  25. Raise the PreSendRequestHeaders event.
  26. Raise the PreSendRequestContent event.
    The MapRequestHandlerLogRequest, and PostLogRequest events are supported only if the application is running in Integrated mode in IIS 7.0 and with the .NET Framework 3.0 or later.

What Is the Difference Between an ISAPI Server Extension and a Filter?

ISAPI Extentions
Runs when referenced in a URL. 
Is explicitly invoked, for example by http://myserver/myprog.dll?. 
Is loaded on demand, the first time a user calls it. 

ISAPI Filters
Is called for every URL the server processes.
Runs automatically for any URL sent to the server if the registered event occurs.
Is loaded when the service starts because of its registry entry.
Both server extensions and filters:

Share the process space of the service.
Must be thread safe.
Once loaded, remain in memory (until the service is stopped or the memory is needed by another process).

If you want to use custom ISAPI filter/extention you gonna write unmanaged code somehow. If its hard to code in more basic in IIS with c++,  you can use managed code  using c#,vb also IIS supports with .net framework and have similar structures at upper level (i mean using aspnet_isapi.dll) and you figure out that  ISAPI Filters are much like HttpModules and ISAPI Extentions are very like HttpHandlers .

See Also