惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
博客园 - Franky
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog
有赞技术团队
有赞技术团队
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
阮一峰的网络日志
阮一峰的网络日志
C
Check Point Blog
爱范儿
爱范儿
T
The Blog of Author Tim Ferriss
aimingoo的专栏
aimingoo的专栏
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LangChain Blog
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
Microsoft Security Blog
Microsoft Security Blog
The Cloudflare Blog
博客园 - 三生石上(FineUI控件)

博客园 - winkingzhang

Build 2016概览 WinRT开发系列之编程语言:功能和效率 WinRT开发系列之基础概念:WinRT不是…… VS2010 Extension实践(3)——实现自定义配置 [VS2010 Extension]PowerExtension.GoToDefinition VS2010 Extension实践(2) VS2010 Extension实践 如何通过反射调用带有ref或者out的参数的方法[迁移] Win7硬盘安装和移动硬盘访问出错的修复办法[迁移] zt. Windows Mobile开发文章收藏 [WPF]在Style中设置ToolTip的问题分析 [WPF]RadioButton在Group的Header区部分不响应鼠标选择的bug分析 WPF模式思考 (zt) How to Get IIS Web Sites Information Programmatically Visual Studio 调试器 Application Request Routing and the IIS 7.0 Web Management Service Reference Resources for MOSS and WSS FileSystemWatcher事件多次触发的解决方法 CAS and Native Code
ASP.NET Application Life Cycle
winkingzhang · 2008-05-28 · via 博客园 - winkingzhang

Original Post at http://blogs.msdn.com/tom/archive/2008/05/27/asp-net-application-life-cycle.aspx

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.