How does IIS process ASP. NET requests?

Source: Internet
Author: User

Original article: http://www.cnblogs.com/hkncd/archive/2012/03/23/2413917.html

Beginner's Guide: How IIS Process ASP. NET Request

Preface

Each time the server receives a request, it must be processed by IIS first. This is not an article about ASP. NE lifecycle, but about IIS operations. Before we start, understanding this will help us understand the full text and welcome feedback and suggestions.

What is Web Server?

".

When we configure a Web program, the word "Web Server" is always involved. Its function is to respond to all requests.

What is IIS?

IIS (Internet Information ServerIs a type of Microsoft Web Server used to configure ASP. NET sites. IIS has its own ASP. NET processing engine to process requests. Therefore, when a request arrives, IIS receives and processes the request and then returns the content.

Request Processing Process

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 understand two concepts:

1. Worker Process)

2. Application Pool)

Worker Process: In iis, the workflow (w3wp.exe) runs ASP.. NET application, manage and respond to all requests, ASP. all the functions of NET are running in the working process. When a Request arrives, the working process generates information related to Request and Response. In short, working processes are at the heart of ASP. NET programs.

Application pool: The application pool is the container of worker processes. It is usually used to separate working processes with different configurations. When a program fails or the process resources are recycled, the programs in other pools will not be affected.

Note: When an application pool contains multiple working processes, it is called "Web Garden ".

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 Mode)

The kernel mode is introduced from IIS 6.0. It contains an HTTP. SYS file. When a request comes in, the file response is triggered first.

The HTTP. SYS file is responsible for transmitting requests to the corresponding application pool. But how does HTTP. SYS know which application pool should be passed? Of course, it is not a random extraction. Every time an application pool is created, the ID of the pool will be generated and registered in the HTTP. SYS file. Therefore, this file can determine where to transfer the request.

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

In the IIS user moduleWeb Admin Services (WAS)Receives requests from HTTP. SYS and transmits them to the corresponding application pool.

When the application pool receives the request, it will be passed to the workflow (w3wp.exe). The process checks the requested URL suffix to determine which ISAPI extension to load. ASP. NET is attached with its own ISAPI extension (aspnet_isapi.dll) for ing in IIS.

Note:: If asp.net is installed first and IIS is installed, you must use the aspnet_regiis command to register the ISAPI extension in ASP. NET.

Once the working process loads aspnet_isapi.dll, it constructs an HttpRuntime class, which is the entry of the application and processes the request through the ProcessRequest method.

Once this method is called, an HttpContext instance is generated. You can get this instance through HTTPContent. Current, And the instance will survive throughout the lifecycle. Through this, we can get some common objects, such as Request, Response, and Session.

Then, HttpRuntime loads an HttpApplication object through the HttpApplicationFactory class. Each request must pass through a bunch of httpmodules to reach HttpHandler for response. 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. You can also customize the HttpModule to perform special processing between request responses.

HttpHandler is the end of the "Http Pipeline. All requests pass through the HttpModule need to arrive at the corresponding HttpHandler, and then HttpHandler generates and outputs content according to the requested resource. Therefore, we request any aspx page to get the Html content of the response.

Conclusion

When you request some information on the Web server, the request first reaches Http. SYS, and then Http. SYS sends it to the corresponding application pool. The application pool sends it to the worker process and loads the ISAPI extension. Then, the HttpRuntime object is created and requests are processed through the HttpModule and HttpHandler.

Finally, the ASP. NET page lifecycle begins.

This is just an article about the IIS processing process. If you want to learn more, click the following link to learn more.

A low-level Look at the ASP. NET Architecture

IIS Architecture

Beginner's Guide: How IIS Process ASP. NET Request

Note:

Then the process will appear.

2. In order to save time, the source image is directly referenced. The English version is poor. Check the dictionary for details.

Related blog posts:

Asp. Net architecture (Http request processing process)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.