How IIS Handles ASP.

Source: Internet
Author: User

English Original: Beginner ' s guide:how IIS Process ASP.

  Objective

Each time the server accepts a request, it is processed by IIS first. This is not an article describing the asp.ne life cycle, just about IIS operations. Before we begin, it will help to understand the full text and welcome feedback and suggestions.

  What is Web Server?

Whenever we run an ASP. NET Web site through VS, the VS Integrated ASP. WebDev.WebServer.exe responds to a variety of requests, the name of which is called "a".

When we configure a Web program, there is always a word "Web Server", and its function is to respond to all requests.

  What is IIS?

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

  Request Handling 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 section. Before you go on, you need to understand two concepts:

1, the work process (worker process)

2. Application pools (application pool)

  worker Process : in IIS, The worker process (w3wp.exe) runs the ASP. NET application, manages and responds to all requests, and all of the functions of ASP. Run under the worker process, and when the request arrives, the worker processes generate request and response related information. In short, the work process is the heart of the ASP.

  Application Pools : Application pools are containers for worker processes and are typically used to separate worker processes from different configurations. Programs in other pools are not affected when a program error or process resource is reclaimed.

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

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

1. Kernel module (Kernel Mode)

2 module (user Mode)

The kernel mode is introduced from IIS 6.0, which contains a file called HTTP. sys, which, whenever requested, triggers the response of the file first.

HTTP. SYS file is responsible for passing requests to the appropriate application pool. But how does http. sys know which application pool should be passed to? Of course 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 determine where the request will be sent.

The above is the first step in IIS processing requests. Next, let's look at how the request is passed in to the application pool from HTTP. sys.

In the user module of IIS, requests are received from HTTP. Sys through Web Admin Services (WAS) and passed in to the appropriate application pool.

When the application pool receives the request, it is then passed to the worker process (w3wp.exe), which examines the requested URL suffix to determine which ISAPI extension to load. Asp. NET is loaded with its own ISAPI extension (Aspnet_isapi.dll) for mapping in IIS.

  Note : If you install ASP. NET before you install IIS, you will need to register the ISAPI extension in ASP. NET by using the aspnet_regiis command.

Once the worker process loads the aspnet_isapi.dll, a httpruntime class is constructed that is the portal to the application and processes the request through the ProcessRequest method.

Once this method is called, an instance of HttpContext is generated. This instance can be obtained through httpcontent.current, and the instance will survive the entire life cycle, where we can get some common objects, such as Request,response,session.

HttpRuntime will then load a HttpApplication object through the HttpApplicationFactory class. Each request passes through a heap of HttpModule to reach HttpHandler to be responded to. And these HttpModule are configured in HttpApplication.

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

The HttpHandler is the endpoint of the HTTP pipeline. All requests pass through the HttpModule to arrive at the corresponding HttpHandler, and then HttpHandler generate and output the content according to the requested resource. As a result, we ask any ASPX page to get a response to the HTML content.

  Conclusion

Whenever some information on the Web server is requested, the request first arrives at 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 through HttpModule and HttpHandler.

Finally, ASP. NET page life cycle begins.

This is just an article that outlines the process of IIS processing, and if you want to learn more about the details, please click on the link below to learn more.

A low-level look at the ASP. Architecture

IIS Architecture

This article translated from: Beginner ' s guide:how IIS Process ASP.

  Small bet after translation:

1, if IIS configured the site but do not see the "w3wp.exe" process, as long as the browser to open one of the station's pages, the "w3wp.exe" process will appear.

2, in order to save time, directly quoted the original, English poor, small check the dictionary should be no problem.

Related blog Posts:

ASP. NET schema (HTTP request processing process)

How IIS Handles ASP.

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.