Asp. NET underlying architecture explore the ASP.net pipeline

Source: Internet
Author: User
Tags httpcontext web services

HttpApplication triggers events to inform your program that something is happening, in order to be responsible for the request flow. This occurs as part of the HttpApplication.Init () function, setting and starting a series of events consecutively.

HttpApplication triggers events to inform your program that something is happening, in order to be responsible for the request flow. This takes place as part of the HttpApplication.Init () function (Reflector view System.Web.HttpApplication.InitInternal () Method and the Httpapplication.resumesteps () method to learn more), set up and start a series of events continuously, including executing all processors (handler). These event handlers map to which events are automatically generated in Global.asax, and they map to all additional httpmodule (which are essentially HttpApplication additional event sinks (sink) that are released externally).

Both HttpModule and HttpHandler are dynamically loaded and attached to the event-handling chain according to the corresponding configuration in web.config. HttpModule is actually an event handler, attached to a special HttpApplication event, but HttpHandler is used to process the endpoint of application-level request processing.

Both HttpModule and HttpHandler are loaded and attached to the call chain in part of the HttpApplication.Init () function call. Figure 6 shows the different events, when they occur, and what part of the pipeline they affect.

Figure 6: The process of the event flowing through the ASP.net HTTP pipeline

Event-driven requests for HttpApplication objects flow through the pipeline. HttpModule can intercept these events and overwrite or extend existing functionality.

HttpContext, HttpModules and httphandlers.

HttpApplication itself knows nothing about the data sent to the application-it's just a message object that communicates through events. It triggers the event and passes the message to the called function by HttpContext the object. The state data of the actual current request is maintained by the HttpContext object mentioned above. It provides all the requested proprietary data and follows the request from the beginning to the end of the entry pipeline. Figure 7 shows the process in the ASP.net pipeline. Note that the context object (that is, the HttpContext), which has always been your "friend" from the start of the request to the end, can hold the information in an event handler and take it out in a later event handler function.

Once the pipe is started, HttpApplication starts triggering events like Figure six. Each event handler is triggered and, if the event is hooked up, the processors perform their own tasks. The main task of this process is to eventually invoke the HttpHandler that is attached to this particular request. The processor (handler) is the core processing mechanism for ASP.NET requests and is usually where all application-level code is executed. Remember that both the ASP.net page and the Web Services framework are implemented as HttpHandler, and this is the core of the processing of requests. Modules (module) tend to become a preprocessing or a post processor that is passed to the context of the processor (handler). Asp. The typical default processors in net include preprocessing authentication, caching, and various coding mechanisms in post processing.

There are a lot of available information about HttpHandler and HttpModule, so in order to keep this article at a reasonable length, I will provide a brief introduction to the processor.

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.