ASP.NET Application Life Cycle

Have you ever wondered about all the stages that an ASP.NET request goes through?  Ever wonder why it is such a performance hit to have a wildcard mapping to map all extensions on your web server to ASP.NET?  This information corresponds to IIS 5.0 and 6.0.  For information on the life cycle in IIS 7.0, see ASP.NET Application Life Cycle Overview for IIS 7.0.  You can also check out the ASP.NET Page Life Cycle Overview for information on what happens once a page is run.

User requests a resource

A request comes into the web server and it will check to see what is mapped to handle the request.  ASP.NET is an ISAPI extension under the web server.

ASP.NET receives the first request for an application

ASP.NET will first create the application domain for this application.  These allow each application to be isolated from each other.  ASP.NET then compiles all the top-level items in the application, if required, including the App_Code folder.

ASP.NET core objects created for the request

ASP.NET will create the Request, Response, and Context objects for the request.  This includes browser information, cookies, headers and everything that the server will respond back to the client with.

HttpApplication is assigned to the request

The application is started by creating the HttpApplication object, taking into account the Global.asax file if it exists.  At this stage, ASP.NET will create any configured modules, such as SessionStateModule to handle Session.

HttpApplication pipeline

The following events occur:

  1. Validate the request – checking for malicious markup
  2. Perform URL mapping
  3. BeginRequest event
  4. AuthenticateRequest event
  5. PostAuthenticateRequest event
  6. AuthorizeRequest event
  7. PostAuthorizeRequest event
  8. ResolveRequestCache event
  9. PostResolveRequestCache event
  10. Find the requested resource, if it is a Page, compile the page
  11. PostMapRequestHandler event
  12. AcquireRequestState event
  13. PostAcquireRequestState event
  14. PreRequestHandlerExecute event
  15. Call ProcessRequest on the HttpHandler
  16. PostRequestHandlerExecute event
  17. ReleaseRequestState event
  18. PostReleaseRequestState event
  19. Response filtering
  20. UpdateRequestCache event
  21. PostUpdateRequestCache event
  22. EndRequest event
  23. PreSendRequestHeaders event
  24. PreSendRequestContent event

Hopefully this will give you a little perspective on all of the different times that you can hook into a request and the different things you can act on.  There are additional things you can do, such as Application_Start events in the global.asax file.  For those and some nice pictures of some of the above data, take a look at the MSDN page here.

Comments (9)
  1. You’ve been kicked (a good thing) – Trackback from

  2. Shail says:


    I really appreciate that you have explained the entire things in very simple words.

    Now just to carry on the discussion, can you please explain these things

    1. What are the things which causes an application to restart ? Say change in connection string in Web.Config or Change in Web.Config file

    2. What makes the entire worker process restarted ?

    3. How IIS can be configured to deliver best performance

    My intention is to make a complete knowledge base, where everything related to ASP.NET infrastructure is available.

    Thank You,


  3. Shail,

    Thanks for the comment.  Here are my answers:

    1. Numerous things can cause it to restart.  Any changes to any of the files the application depends on will cause it to restart.  The config files are just a few of them

    2. Crashes can cause the process to restart, or if it hits one of the health monitoring limits.

    3. Configuring IIS really depends on what you are doing with it, take a look at this post for some places to start:

    Keep the questions coming…

  4. Shail says:


    Thank you very much for answers.

    There are few more questions

    1. Is there is any tool which can be just attached to your IIS and it will give you all the information about application performance, even at the page level and of course in graphical way. So that you can find whats wrong with the application. I think thats even better for Administrators. Thats something performance counters and Windows logs can do for you.

    2.How can I set my IIS and other ASP.NET process such as Worker process as High Priority processes in my OS. For example, I have other application like anti virus. So I want to achieve the performance from the level of CPU. I wanna instruct my machine that keep the IIS and ASP.NET as the top priority application.

    3. Now we have Multi-Core CPUs, is that possible that  I can write my ASP.NET code ( Say business classes ) in such a way, So that the money I paid to have a Multi-Core CPU is utilized.

    Thank You,


  5. Shail,

    For #1, the best we currently have is DebugDiag:

    It does a very nice job bringing everything together.

    For #2, take a look at:

    Also, in the performance options, switch to the Advanced tab and change the "Adjust for best performance of:" to Background services.

    For #3, ASP.NET will use multi-core for .NET, if you want to write your code to use it more, there are some exciting things coming down the pipe.  Keep checking this blog and I’ll write about them soon.

  6. Subi says:

    Good Post Tom, i really appreciate even Shail’s queries are also nice.

    Can you give some idea to remove javascript error from a web page (very common error in web development)using IE8 or IE7.

  7. Subi,

    Typically that is caused by WebResource.axd problems.  One such problem is discussed

    The problem really depends on what is causing the javascript error.  If it isn’t WebResource then you need to see what the error is and determine what can be done to fix it.

  8. Scott says:

    We have a ASP.Net web application.  I have been told that the initial request takes too long to bring up our Launch Page.  I added trace output all along the HttpApplication pipeline lifecycle.  I noticed that there is a 7 second (average) delay between the PostResolveRequestCache event and PostMapRequestHandler event.  The pipeline lifecycle above states that between these events the application will "10. Find the requested resource, if it is a Page, compile the page ".

    Is there a way I can precompile the pages so this step can be faster?  I have tried using the Publish… option in VS but this still seemed to have this delay.

    I also placed a .htm page in this web application.  The htm page loads the Launch Page into an IFRAME.  On the initial request to the application there is a 10 second delay between the htm page displaying in the browser and the Application_Start event.  Is there anyway to speed this up?

    After the initial request to the application has been handled then all subsequent requests do not experience these delays.

    Any ideas or suggestions you have would be greatly appreciated.



Comments are closed.

Skip to main content