IIS is how to deal with ASP.NET request
Every time the server receives the request, should be treated first by IIS.ASP. This is not an NE life cycle, and is only related to the IIS operation.Before westart to understand these will contribute to understanding of the full text, at the same time welcome feedback and Suggestions.
What is a Web Server?
Whenever we through ASP.NET, run VS VS integration of ASP.NET engine will respond to all requests, the engine is the name of "WebDev. WebServer. Exe.
When we configure a Web application will always involve a word "Web Server", its function is to respond to all requests.
What is the IIS?
IIS (Internet Information Server) is one of the Microsoft Web Server, used to configure the ASP.NET site.IIS has its own ASP.NET processing engine to handle the request, therefore, when a request arrives, the IIS to receive and process the request, and then return.
Now, you should be able to understand the difference between a Web Server and IIS.Now let's look at the core part.Before proceeding, you need to clarify two concepts:
1, the work Process (the Worker Process)
2, the Application Pool (Application Pool)
Work in progress: in IIS, work in progress (w3wp.exe) run the ASP.NET application, management and respond to all requests, ASP.NET all functions are running in the working process, when the Request arrives, work process will generate the Request and Response related information.In short, the work process is the heart of ASP.NET application.
Application pool: application pool is the container of the work process, often used to separate different configuration of work process.Error when a program or process recycling, the other in the pool program will not be affected.
Note: when an application pool contains multiple work process, is called "Web Garden".
If we look at the structure of the IIS 6.0, we will find that you can divide it into two parts:
1, the Kernel module (Kernel Mode)
2, User module (User Mode)
Kernel mode from the IIS 6.0 is introduced, it includes a called HTTP. SYS file, when requests come in, will trigger the response of the document in the first place.
HTTP. SYS file is responsible for the request to the corresponding application pool.But HTTP. SYS should how to know to which application pool?, of course, is not random, when creating an application pool, the pool ID will be generated and in HTTP. SYS file registration, so the file to determine the request where the.
This is the IIS the first step to handle the request.Then, let's look at how from the HTTP request. The SYS incoming application pool.
In the IIS user module, through the Web Admin Services (WAS) from the HTTP. SYS receives the request, and into the appropriate application pool.
When the application pool receives the request, will then (w3wp.exe) to the work process, the process inspection to the requested URL suffix to determine which load the ISAPI extension.ASP.NET is loaded with own ISAPI extension (aspnet_isapi.dll), in order to map in IIS.
Note: if you install the first asp.net, then install IIS, you need to pass aspnet_regiis commands to register the asp.net ISAPI extension.
Work process loaded the aspnet_isapi. DLL, can construct a the HttpRuntime class, the class is the entry of the application, through the ProcessRequest method processing the request.
Once this method is invoked, a HttpContext instance is created.Through HTTPContent. The Current access to the instance, and the instance will survive in the entire life cycle, through which we can get to some commonly used objects, such as the Request, the Response, the Session, etc.
After the HttpRuntime will pass HttpApplicationFactory class loading a HttpApplication object.Every request to go through a pile of an HttpHandler HttpModule arrive, so that was the response.And these HttpModule is configured in the HttpApplication.
Have a concept called "Http pipeline", called pipeline because it contains a series of HttpModule, these HttpModule corresponding an HttpHandler intercept requests and guide it.We can also custom HttpModule, in order to do something special between request and response processing.
An HttpHandler is the end of pipe "" Http.All requests through the HttpModule need to reach the corresponding an HttpHandler, then an HttpHandler according
to request resources, produce and output content.Is, therefore, we request any
aspx page will get the response Html content.