Operating principle and mechanism of ASP. NET

Source: Internet
Author: User

After an HTTP request is sent to the server and received by IIS, IIS first loads the corresponding page type requested by the client. DLL file, and then send the request to the module that can process the request. In ASP. NET 3.5, this module is called httphandler (HTTP ProcessingProgramThe reason why the. aspx file can be processed by the server is that the default httphandler is used to process the. aspx file on the server. Before IIS sends this request to a module that can process this request, it also needs to process some httpmodule, which are default modules of the system (used to obtain the module set of the current application ), before the HTTP request is sent to httphandler, it must be processed by different httpmodules. The benefits of doing so are: first, for some necessary processes, second, for security, third, to improve efficiency, and fourth, to allow users to control more links, enhance user control capabilities. The operating principle of ASP. NET 3.5 is shown in 1.1.

 
Figure 1.1 operating principles of ASP. NET 3.5

Note: The httpmodule module is a component that can be registered as part of the ASP. NET 3.5 request lifecycle. When processing this component, it can read or change the request or response. The httpmodule module is usually used to execute special tasks that need to monitor each request, such as security or site statistics.

(PS:

Httpmodule Overview:

We will not consider implementing the HTTP module on our own. In. net, the HTTP module is an assembly that implements the ihttpmodule interface. The ihttpmodule interface does not have any upper-case close-up functions. It can be identified by its name. It is just an ordinary interface. In fact, we care about the classes that implement these interfaces. If we writeCodeWhat is the purpose of implementing this interface. In general, we can set ASP.. Net events are divided into three levels: application-level events, page-level events, and control-level events, the event trigger is closely related to the application cycle, page cycle, and control cycle.The role of the HTTP module is closely related to application events.

We use the HTTP module to register the method expected to respond to application events in the HTTP request pipeline (pipeline). When the corresponding event is triggered (such as the beginrequest event, when an application receives an HTTP request and is about to process it), it calls the method registered by the HTTP module. The actual work is executed in these methods .. Net itself already has many HTTP modules, including form verification module (formsauthenticationmodule), session Status Module (sessionstatemodule), and output cache module (outputcachemodule.

Learn more: http://www.cnblogs.com/jimmyzhang/archive/2007/11/25/971878.html

)

ASP. NET 3.5 Operating Mechanism 1.2.

Usually, Asp. the. NET framework is built on Windows Server (server version) + IIS (Web server, short for Internet information service manager. net Framework, the installer registers ASP. NET in IIS.. Net (aspnet_isapi.dll. after receiving the HTTP request from the client, the IIS of the net host gives the control of the Response Request to ASP.. net.

ASP. when the net runtime receives the request, it will determine whether the site is accessed for the first time. If it is accessed for the first time, it will run the initialization work (such as loading the DLL dynamic link library in the bin directory and reading the web. config website configuration file, initialize httpapplication instance, compile and load global. asax files ). ASP. NET is also responsible for creating the httpcontext context instance of the Request Response thread and the httptextwriter instance that carries the response result when it is running. Then, when ASP. NET is running, find the appropriate httphandler (usually an ASP. NET page) to process the HTTP request, and wait for httphandler to return the request processing result. Finally, the ASP. NET runtime completes some subsequent work, such as saving session and exception handling, and then returning the response structure to the client through IIS.

 
Figure 1.2 ASP. NET 3.5 Operating Mechanism

Note: the main task of ASP. NET isapiis to prepare aspnet_wp.exe to process the request and monitor that the ASPNET _ worker process cannot complete the task. ASP. NET isapiwill arrange a new aspnet_wp.exe to process the task. The main task of aspnet_wp.exe is to send requests to a series of hosted objects called HTTP pipelines. If ASP. NET isapiis used as a seller, aspnet_wp.exe is the producer, HTTP pipeline is the production pipeline, and the team responsible for the pipeline is httpruntime. The producer aspnet_wp.exe will hand over the order (HTTP request) to the httpruntime team's processrequest (httpworkerrequest wr). According to the internal division of labor, the httpruntime is finally produced on the pipeline by processrequestinternal (httpworkerrequest wr.

Transferred from:Http://book.51cto.com/art/201001/181147.htm

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.