ASP. NET ISAPI

Source: Internet
Author: User

No matter which underlying platform is used, reliability and performance are the main requirements for all Web applications, although in a sense, these two requirements are conflicting. For example, to build a more reliable and robust application, you may need to separate the Web server from a specific application so that the application can work outside the process. However, if you work in a memory environment different from the Web server process, the application slows down. Therefore, reasonable measures must be taken to ensure that code outside the process runs as quickly as possible.

In building Microsoft®When ASP. NET is running, the reliability and performance are fully considered. The obtained ASP. NET process model contains two system elements: one in-process connector in the Web server process and one external auxiliary process. In addition, the ASP. NET runtime architecture is highly scalable and can automatically use any processor selected in the multi-processor hardware. This mode is called "Web Garden". It allows multiple auxiliary processes to run simultaneously, and each process is in an independent processor.

In summary, ASP. NET runtime has three attributes:

◆ The application and the ASP. NET auxiliary process are completely separated. The life of the auxiliary process that provides services will never affect the life of the application. In other words, the secondary process can be terminated at any time when the application is started and running.
◆ Although ASP. NET applications never run in the process on the Web server, the overall performance of ASP. NET applications is close to that of in-process applications in most cases.
◆ Provides built-in and configurable support for the Web Garden architecture. You only need to check the settings in the configuration file, and the secondary process can clone itself to take advantage of all CPU resources that are closely related to the process. Therefore, in most cases, the scalability you obtain on a computer with a multi-processor will grow linearly. This article will be detailed later .)

This article introduces the components of the ASP. NET runtime environment, and then describes the process of changing from a URL request to a pure HTML text one by one.

Unless otherwise specified, the default Process Model of ASP. NET, Microsoft®The unique model in Internet Information Services (IIS) 5.x.
ASP. NET Component

The execution of ASP. NET applications requires the support of the host Web server. In Microsoft®Windows®The Web Server is represented by an IIS Executable File named inetinfo.exe. Windows 2000 and later versions provide Web servers. Note that®In Windows Server & #153; 2003, IIS and ASP are not installed by default.. NET, you must add it to the system by clicking the add or delete programs Applet in the control panel.

IIS is an unmanaged executable program that provides an extensible Model Based on the ISAPI extension module and filter module. By writing such a module, developers can directly manage requests for a specific resource type and receive the current request in each predefined step. Extensions and filters are some DLL that can be used to export functions with known names and signatures. These plug-in components are registered and configured in the IIS configuration database.

Only a few types of resources requested by the client are directly processed by IIS. For example, IIS processes incoming requests to HTML pages, text files, JPEG and GIF images. Requests to the Active Server Page (*. asp) file are parsed by calling the asp extension module named ASP. dll. Similarly, requests for ASP. NET resources such as *. aspx, *. asmx, and *. ashx are passed to ASP. net isapi extensions. The system component is a Win32 DLL named aspnet_isapi.dll. ASP. NET extensions can handle multiple resource types, including Web Services and HTTP processing program calls.

ASP. net isapi extension is a Win32 DLL that is not integrated with managed code. It is the control center for receiving and distributing requests from various ASP. NET Resources. According to the design, this module exists in the IIS process and runs under the SYSTEM account with administrator permissions. Developers and System Administrators cannot modify this account. ASP. net isapi extension is responsible for calling the ASP. NET auxiliary process (aspnet_wp.exe) and controlling the execution of requests. In addition to request arrangement, ASP. net isapi also monitors the running status of the auxiliary process and cancels the process when the performance is reduced to a certain extent.

A helper process is a short Win32 shell code that integrates the Common Language Runtime Library (CLR) and runs managed code. It processes requests to ASPX, ASMX, and ASHX resources. Generally, this process has only one instance in a given computer. All currently activated ASP. NET applications run in it, and each application is located in an independent AppDomain. However, as mentioned above, the secondary process supports the Web Garden mode, that is, the same copies of the process run on the CPU closely related to the process. For more information, see "Web Garden model .)

Communication between ISAPI and auxiliary processes is performed using a set of named pipelines. A named pipe is a Win32 mechanism used to transmit data across process boundaries. As the name implies, a named pipe works in a similar way as a pipe: It inputs data at one end and outputs the same data at the other end. The created MPs queue can connect both local processes and processes running on a remote computer. For communications between local processes, pipelines are the most effective and flexible tools in Windows.

To ensure optimal performance, aspnet_isapi uses an asynchronous naming pipeline to forward requests to the secondary process and obtain responses. On the other hand, the auxiliary process uses the synchronization pipeline when it needs to query information about the IIS environment, that is, the server variable. The aspnet_isapi module creates a fixed number of named pipelines and uses overlapping operations to process connections at the same time through a small thread pool. After the data exchange operation is completed through the pipeline, the completion routine will disconnect the client and re-use the pipeline instance as the new client service. The thread pool and overlapping operations can ensure that the performance of ASP. net isapi can reach a satisfactory level. However, the aspnet_isapi extension will never process HTTP requests.

The processing logic of ASP. NET requests can be summarized as follows.

1. When the request arrives, IIS checks the resource type and calls ASP. net isapi extension. If the default process model is enabled, aspnet_isapi queues requests and assigns them to the secondary process. All request data is sent through asynchronous I/O. If the IIS 6 process model is enabled, requests are automatically queued in the secondary process (w3wp.exe), which is used to process the IIS application pool to which the application belongs. The IIS 6 auxiliary process does not understand ASP. NET and the managed code in any situation. It only processes *. aspx extensions and loads the aspnet_isapi module. When ASP. net isapi is run in the IIS 6 process model, it works in different ways. It only loads CLR in the context of the w3wp.exe auxiliary process.
2. After receiving the request, the ASP. NET auxiliary process will notify ASP. net isapi that it will serve the request. Notifications are implemented through synchronous I/O. The synchronous model is used because the secondary process can process a request only when it is marked as "executing" in the ISAPI internal request table. If a request has been processed by a special auxiliary process, it cannot be specified to another process unless the original process has been canceled.
3. execute the request in the context of the auxiliary process. Sometimes, the Helper process may need to call back ISAPI to complete the request, that is, to enumerate server variables. In this case, the secondary process uses a synchronization pipeline because it can maintain the order of request processing logic.
4. After completion, the response is sent to the aspnet_isapi that opens the asynchronous pipeline. Now, the Request status changes to "Done" and will be deleted from the request table. If the secondary process crashes, all the requests being processed will remain in the "executing" status for a period of time. If aspnet_isapi detects that the secondary process has been canceled, it will automatically terminate the request and release all related IIS resources.

  1. Analysis on ASP. NET Web Security
  2. Session State of ASP. NET
  3. Analysis on the attribute ASP. NET of IsPostBack
  4. ASP. NET architecture and security mechanism
  5. Overview ASP. NET Crystal Reports

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.