| ASP.NET Application Phases |
| |
| Compilation Life Cycle |
| |
| When the first request is made to an application, ASP.NET compiles application items in a specific order. The first items to be compiled are referred to as the top-level items. After the first request, the top-level items are recompiled only if a dependency changes. The following table describes the order in which ASP.NET top-level items are compiled. |
| |
| ASP.NET compiles Global.asax file into a class derived from the HttpApplication class, and then uses the derived class to represent the application. An instance of HttpApplication processes only one request at a time. |
| |
| ASP.NET automatically binds application events to handlers in the Global.asax file using the naming convention Application_event, such as Application_BeginRequest. This is similar to the way that ASP.NET page methods are automatically bound to events, such as the page's Page_Load event. |
| |
| The Application_Start and Application_End methods are special methods that do not represent HttpApplication events. ASP.NET calls them once for the lifetime of the application domain, not for each HttpApplication instance. |
| |
| The compilation order of ASP.NET top-level items are explained in the following listing: |
| |
| Item |
| |
1. App_GlobalResources
2. App_WebResources
3. Profile properties defined in the Web.config file
4. App_Code
5. Global.asax |
| |
| Once the application's top level items have been compiled, ASP.NET compiles folders, pages, and other items as needed. The compilation order of ASP.NET folder and items are explained in the following listing. |
| |
| Item |
| |
1. App_LocalResources
2. Individual Web pages (.aspx files), user controls (.ascx files), HTTP handlers (.ashx files), and HTTP modules (.asmx files)
3. Themes, master pages, other source files |
| |
| Compiled assemblies are cached on the server and reused on subsequent requests and are preserved across application restarts as long as the source code is unchanged. |
| |
| Because the application is compiled on the first request, the initial request to an application can take significantly longer than subsequent requests. You can precompile your application to reduce the time required for the first request. |
| |
|
| |