Asp.net Architecture
Processing of Asp.net requests
-------------------
What must be mastered by httpmodule
What httphandler must master is very useful
The above two instances
---------------------
Asp.net event model Mechanism
-----------------------
I
The customer's request page is processed by the dynamic Connection Library aspnet_isapi.dll, which sends the requested aspx file to CLR for compilation and execution, and then returns the HTML stream to the browser.
--------------------------
2. Page events
Execution sequence
Page_init: initialization value or connection
Page_load: mainly uses ispostback. This event mainly performs a series of operations to create an Asp.net page or response for the first time.
Client events caused by shipping. The page and control view status have been restored before this event.
Page_databind: it can be called at the page level or in a single control.
Databind_prerender: Pre-rendering of data binding, which is triggered just before the view status and Rendering Control are saved.
Page_unload: This event executes the final cleaning.
Uncertain event
Page_error: if an unhandled exception occurs during page processing, an error event is triggered.
Page_aborttransaction: Transaction event. If a transaction has been terminated during transaction processing, this event is triggered and is commonly used in shopping carts.
Page_committransaction: this event is triggered if the transaction is successful.
--------------------------------------------------------
Events in global. asax (execution sequence)
Application_start: Application Program Triggered at startup
Application_beginrquest: triggered when an HTTP request starts.
Application_authenticaterequest: triggered when the application approves an HTTP request
Session_start: triggered when the session is started
Application_endrequest: triggered when the htttp request ends
Session_end: triggered when the session ends
Application_end: triggered when the application ends
Application_error: triggered when an error occurs.
----------------------
ISAPI: inserts some components into the web server to expand the functions and enhance the functions of the Web server.
ISAPI: extended, Win32 dynamic link library, such as aspnet_isapi.dll, can regard ISAPI extension as a common application, which processes HTTP requests.
ISAPI: filter. The web server sends the request to the related filter. Next, the filter may modify the request and perform some operations.
Processing of ASP. NET requests:
Based on the pipeline model, ASP. NET transmits HTTP requests to all modules in the pipeline. Each module receives HTTP requests and has full control. Once the request passes through all the HTTP modules, it is finally processed by the HTTP processing program. The HTTP handler processes the request and the result passes through the HTTP module in the module pipeline again.
-----------
Httpmodule
ISAPI filter: IIS itself does not support dynamic pages, that is, it only supports static html page content,. ASP. aspx. CGI. PHP, etc. IIS does not know that if these suffix tags are processed, it will treat it Composition This will not be processed and sent to the client at all. To solve this problem, IIS has a mechanism called ISAPI filter. It is a COM component.
When the ASP. NET service registers to IIS, it registers the file extensions that each extension can process to IIS (for example, *. ascx *. aspx ). After the extension is started, it processes the files that cannot be processed by IIS according to the defined method, and then redirects the control to the dedicated ProcessingCode In the process, Asp.net is aspnet_isapi.dll. Let this process start to process the code, generate standard HTML code, add the code to the original HTML, and finally return the complete HTML to IIS, IIS then sends the content to the client.
----------------
Httpmodule
The HTTP module implements the ISAPI filter function, which is a. NET component that implements the system. Web. ihttpmodule interface .. These components register themselves in some events and insert themselves into the ASP. NET Request Processing pipeline. When these events occur, ASP. NET calls the HTTP module that is interested in the request, so that the module can process the request. Sometimes you need to worry over the HTTP request. Note that it does not overwrite other HTTP modules that come with the system. The configuration is complete in machine. config.
--------------------------------------
Httphandler
It implements the ISAPI extention function, which processes the request information and sends the response ). The ihttphandler interface must be implemented through the httphandler function. The HTTP handler is A. NET component that implements the system. Web. ihttphandler interface. Any class that implements this interface can be used to process input HTTP requests. It is an HTTP processing program.