The reason why HTTP is so successful is the simplicity of its design and implementation and the high efficiency of stateless connections. To balance stateless HTTP requests with stateful client operations, the concept of server-side Session is introduced. After the client connects to the server, the Web server generates and maintains a client session. When the client connects to the server again through the stateless HTTP protocol, the server submits a Credential Based on the client, for example, Cookie or URL parameters are used to associate a customer with a session. This idea is widely used in various development languages and environments.
In ASP. NET, the Web application and session state are maintained separately, and the Web application and session functions are separated through HttpApplication and HttpSessionState. The Application Layer logic is in Global. implemented in the asax file and compiled into System at runtime. web. httpApplication instance; Session is used as a separate System. web. sessionState. the HttpSessionState instance is maintained by the server for each user session.. NET page compiled into the System. web. UI. access the Session attribute of the Page Object subclass. For more information about the different levels of ASP. NET, see my previous article ". NET 1.1 Pre-compiled ASP. NET page implementation principle analysis automatic pre-compilation Mechanism Analysis".
When processing client requests, ASP. NET first generates a System. Web. HttpContext object based on the client environment and passes the object as the execution context to the subsequent page for code execution.
We can see that HttpRuntime constructs an HttpContext object based on the environment given in HttpWorkerRequest before processing the page request, and obtains available applications from the application pool using the secondary object as the parameter. The brief code is as follows:
The following is the program code:
- Private void HttpRuntime. ProcessRequestInternal (HttpWorkerRequest wr)
- {
- // Construct the HTTP call context object
- HttpContextCtxt=NewHttpContext (wr, 0 );
- //...
- // Obtain the current Web application instance
- IHttpHandlerHandler=HttpApplicationFactory. GetApplicationInstance (ctxt );
- // Call handler to actually process page requests
- }
The Web applications in ASP. NET are described as follows:
- Data source controls in ASP. NET
- Introduction to the use of XML Web Services in ASP. NET
- Web. config file of ASP. NET application
- Overview ASP. net xml Web Services
- Implement HTTP requests in ASP. NET