Explain how IIS web server handles ASP.NET requests (Figure)

  
                  

Each time the server receives a request, it must be processed by IIS. This is not an article describing the life cycle of asp.net, just about IIS operations. Before we get started, understanding these will help to understand the full text, and welcome feedback and suggestions.

What is Web Server?

Whenever we run ASP.NET through VS, the VS-integrated ASP.NET engine responds to various requests. The name of this engine is “WebDev .WebServer.exe”.

When we configure a web application, it always involves a word "Web Server", which is designed to respond to all requests.

What is IIS?

IIS (Internet Information Server) is a Microsoft Web Server, used to configure ASP.NET site. IIS has its own ASP.NET processing engine to handle requests, so when a request arrives, IIS receives and processes the request and then returns the content.

request processing

Now, you should be able to figure out the difference between Web Server and IIS. Now let's take a look at the core part. Before proceeding, you need to figure out two concepts:

1. Worker Process

2. Application Pool

Work Process: In IIS, the worker process (w3wp.exe) runs an ASP.NET application that manages and responds to all requests. All ASP.NET functions run under the worker process. When the request comes in, the worker process generates a Request and Response related information. In short, the work process is the heart of the ASP.NET program.

Application Pool: An application pool is a container for worker processes and is typically used to separate work processes of different configurations. When a program fails or process resources are reclaimed, programs in other pools are not affected.

Note: When an application pool that contains multiple worker processes, called & ldquo; Web Garden & rdquo ;.

If we look at the structure of IIS 6.0, we will find that it can be divided into two parts:

1, Kernel Mode

2, user module (User Mode)

Kernel mode was introduced from IIS 6.0. It contains a file called HTTP.SYS that triggers the response of the file whenever a request comes in.

HTTP.SYS file is responsible for the incoming request the appropriate application pool. But how does HTTP.SYS know which application pool should be passed to? Of course, it is not randomly extracted. Whenever an application pool is created, the ID of the pool is generated and registered in the HTTP.SYS file, so the file can be determined. Request where to pass.

The above is the first step in IIS to process the request. Next, let's take a look at how the request is passed into the application pool from HTTP.SYS.

In the user module of IIS, the request is received from HTTP.SYS via Web Admin Services (WAS) and passed to the corresponding application pool.

When the URL suffix application pool receives a request, it then passed to the worker process (w3wp.exe), the process to check request to determine which ISAPI extensions loaded. ASP.NET will ship with its own ISAPI extension (aspnet_isapi.dll) for mapping in IIS.

Note: If you install asp.net and then install IIS, you need to register the ISAPI extension in ASP.NET with the aspnet_regiis command.

Aspnet_isapi.dll loaded once the work process, it will construct a HttpRuntime class that initiates an application, the processing request by ProcessRequest method.

Once this method is called, an instance of HttpContext arises. This instance can be obtained through HTTPContent.Current, and the instance will survive the entire life cycle, through which we can get some common objects, such as Request, Response, Session, and so on. After

HttpRuntime loads a HttpApplication object by HttpApplicationFactory class. Each request goes through a bunch of HttpModules to the HttpHandler in order to be responded. These HttpModules are configured in HttpApplication.

There is a concept called "Http Pipeline", called Pipeline because it contains a series of HttpModules that intercept requests and direct them to the corresponding HttpHandler. We can also customize the HttpModule to do some special processing between request responses.

HttpHandler is & ldquo; Http conduit & rdquo; end. All requests passing through the HttpModule need to reach the corresponding HttpHandler, and then the HttpHandler generates and outputs the content according to the requested resource. For this reason, we request any aspx page to get the Html content of the response.

Conclusion

whenever certain information on the Web server a request that arrives first Http.sys, Http.sys then sends it to the appropriate application pool The application pool is passed to the worker process and the ISAPI extension is loaded, then the HttpRuntime object is created and the request is processed via HttpModule and HttpHandler.

Finally, the ASP.NET page life cycle begins.

Copyright © Windows knowledge All Rights Reserved