| ASP.NET Application Phases |
| |
| Web Application Processing |
| |
| In ASP.NET, several processing steps must occur for an ASP.NET application to be initialized and process requests. When a page runs, the page goes through a life cycle in which it executes a series of processing steps. When a page request is sent to the Web server then this processing include initialization, instantiating controls, restoring and maintaining state, running event handler code, and rendering. |
| |
| Execution of a Web Page |
| |
| When a user makes a request from Client (Browser) then the Server or Web server in turn process the request and sends response back to the client in according to the clientâs request. |
| |
| To know about the internal processing running in the web server initially you should know about the structural design of the IIS. |
| |
| It principally is consist of following: |
| |
1. Inetinfo.exec
2. ISAPI Filer (Container for Internet Server Application Interface dlls),
3. Worker Process (aspnet_wp.exe) |
| |
| Handling Client Request |
| |
| When a request coming from client then this request is handled by Inetinfo.exe, which is the ASP.Net request handler. When a Web server receives a request, it examines the file name extension of the requested file, determines which ISAPI extension should handle the request, and then passes the request to the appropriate ISAPI extension. If requested page have static resources like HTML files or image files then inetinfo.exe process the request and sent to client. If the request is with extension aspx/asp, inetinfo.exe processes the request to API filter. ISAPI filter contains many runtime modules called as ISAPI extensions. The runtime module loaded for ASP page is asp.dll. And for ASP.NET page it's ASPNET_ISAPI.dll. From this point the request is processed to the worker process by aspnet_wp.exe. This Worker Process will have several application domains. |
| |
| Application Domain |
| |
| When ASP.NET receives the first request for any resource in an application, a class named ApplicationManager creates an application domain. Application domains provide isolation between applications for global variables and allow each application to be unloaded separately. Within an application domain, an instance of the class named HostingEnvironment is created, which provides access to information about the application such as the name of the folder where the application is stored. |
| |
| An application domain is created automatically by the CLRHost for a new application. The purpose of the application domain is in order to isolate one application from another. The Worker process will create a block of memory related to particular C for bootstrapping the common language runtime before an application is run. |
| |
| Worker process sends the request to HTTPPIPE line. The HTTP Pipeline is collection of .net framework classes. HTTP Pipeline compiles the request into a library and makes a call to HTTP runtime and runtime creates an instance of page class |
| |
public class MyPage : System.Web.UI.Page
{} |
| |
| ASP.Net web page is a class derived from page class, this page class which resides in system.web.dll. After creating instance pf page class HTTP Runtime immediately invokes ProcessRequest method of page class |
| |
| The Process Request Method performs following things: |
| |
1. Initialize the memory
2. Load the view state
3. Page execution and post back events
4. Rendering HTML content
5. Releasing the memory |
| |
|
| |