19 Key segments of the ASP. NET MVC request processing pipeline life cycle (1-6)

Source: Internet
Author: User

Asp. NET and ASP. HttpApplication request processing pipelines have common parts and differences, this series will experience the 19 key aspects of the ASP. Web MVC request processing pipeline life cycle.

① take IIS6.0 as an example, the first is to maintain a working process by w3wp.exe


② If this is the first time loading, the. NET runtime is loaded by Aspnet_isapi.dll


③ A worker process has an application pool, which can host more than one application domain appdomain


④http.sys receive requests, create application domain appdomain through application domain factory appdomainfactory


⑤ a isapiruntime is loaded and a Isapiworkerrequest object is created to encapsulate the current HTTP request and pass the Isapiworkerrequest object to the HttpRuntime runtime of ASP. HTTP request begins entry to ASP. NET Request Pipeline


That is, httpruntime is the entry for the ASP. NET request pipeline. When the request comes in, first enter httpruntime, and the httpruntime decides how to handle the request. By default, the HttpRuntime node is not explicitly defined in Machine.config and Web. config, but the node has a default value, as follows:


<httpRuntime apartmentthreading="false"appRequestQueueLimit=" the"delayNotificationTimeout="5"Enable="true"enableheaderchecking="true"Enablekerneloutputcache="true"Enableversionheader="true"Encodertype="System.Web.Util.HttpEncoder"executiontimeout=" the"Maxquerystringlength="2048"maxRequestLength="4096"Maxurllength="260"maxwaitchangenotification="0"minFreeThreads="8"minLocalRequestFreeThreads="4"relaxedurltofilesystemmapping="False"Requestlengthdiskthreshold=" the"requestpathinvalidcharacters="<,>,*,%,&,:,\ "Requestvalidationmode ="4.0"Requestvalidationtype="System.Web.Util.RequestValidator"requireRootedSaveAsPath="true"Sendcachecontrolheader="true"shutdowntimeout=" -"useFullyQualifiedRedirectUrl="false"waitchangenotification="0"/>

In general, we can change the default value of the HttpRuntime node in Web. config as follows:

<configuration> <system.web> "4000"Enable="True"Requestlengthdiskthreshold=" +Usefullyqualifiedredirecturl="True"executiontimeout=" $"Versionheader="1.1.4128"/> </system.web></configuration>

⑥httpruntime maintains a httpapplication pool, and when an HTTP request comes in, pick an available HttpApplication processing request from the pool


The HttpApplication has 19 pipeline events, namely:

1, the BeginRequest event is triggered when the Beginrequest:http pipeline starts processing the request2, AuthenticateRequest: The security module triggers the event when the request is authenticated3, Postauthenticaterequest: The security module triggers the event after the request is authenticated4, AuthorizeRequest: The security module triggers the event when the request process is authorized5, Postauthorizerequest: The security module triggers the event when the request process is authorized6, Resolverequestcache: The cache module triggers the event when it responds directly to the request process using the cache7, Postresolverequestcache: The cache module triggers the event after it responds directly to the request process using the cache8, Postmaprequesthandler: For access to different resource types, ASP. NET has different HttpHandler for its process processing. For each request, ASP. NET chooses to match the appropriate HttpHandler type according to the extension, triggering the event after a successful match9, AcquireRequestState: The state management module gets the event that is triggered based on the corresponding state of the current request (such as sessionstate)Ten, Postacquirerequeststate: The state management module gets the event triggered based on the corresponding state of the current request (such as sessionstate) One, PreRequestHandlerExecute: Triggers the event before HttpHandler is implemented A, PostRequestHandlerExecute: Triggers the event after HttpHandler has been implemented -, ReleaseRequestState: This event is triggered when the state management module releases the corresponding state based on the current request -, Postreleaserequeststate: The State Management module releases the event based on the corresponding state of the current request the, Updaterequestcache: The cache module triggers the event when the HttpHandler processing request is saved to the output cache accordingly -, Postupdaterequestcache: The Cache module fires the event after the corresponding HttpHandler processing request is saved to the output cache -, Logrequest: This event is triggered for the current request process log record -, Postlogreques: This event is triggered after logging for the current request process +, EndRequest: This event is triggered when the entire request processing is complete

We can customize the pipeline events in the global profile global.asax, according to the agreed rules application_{event Name}:

void Application_Start (object  sender, EventArgs e) {}void application_end (object  sender, EventArgs e) {}void application_error (object  sender, EventArgs e) {}void session_start (object  sender, EventArgs e) {}void session_end (object  sender, EventArgs e) {} ...

Not to be continued ~ ~

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.