Asp. NET Core Processing Technology Introduction

Source: Internet
Author: User
Tags http request httpcontext log

Asp. NET application objects

Processing parameters of the request: Context object HttpContext

When a request arrives at the ASP.net server, in order to process the request, ASP.net creates an object of HttpRequest type on the server to represent the request parameter, and the HttpResponse type of object represents the processing object of the response, that is, in order to process an HTTP request, we need a multitude of pairs, like a table Shows the data required to process the request, in order to simplify server-side processing of the parameters, ASP. NET defines the HttpContext type to uniformly handle the presentation of parameters.

Second, Application object HttpApplication

When the HttpContext object is created, httpruntime will then create an object to process the request, the type of which is HttpApplication. It is an important object for processing requests in asp.net, but it is created by ASP.net, in order to facilitate the expansion of processing work, HttpApplication the process of handling the pipeline, that is, the processing is divided into several steps, each step by writing events in the form of exposure to programmers, these events are in a certain order a Trigger, we can customize the extension process for each request by writing an event-setting method.

Let's take a look at the 19 standard events of HttpApplication

1 beginrequest ASP. NET starts processing the first event that represents the start of the process

2 authenticaterequest authentication request, typically used to process the user information of the request

3 Postauthenticaterequest has obtained the requested user information

4 AuthorizeRequest authorization, generally used to check whether the user's request to get permission

5 Postauthorizerequest user request has been authorized

6 Resolverequestcache gets the processing result of the previous processing cache, if previously cached, no longer need to do the request processing, directly returns the result of the cache

7 Postresolverequestcache has completed the cache acquisition work

8 Postmaprequesthandler has created a Processor object to process the request based on the user's request

9 Acrequirerequeststate The status of the request, generally used for session

Ten Postacrequirerequeststate has already made the session

One prerequesthandlerexcute ready to execute the handler

A handler has been executed in Postrequesthandlerexcute

ReleaseRequestState Release Request Status

The Postreleaserequeststate has released the requested status

Updaterequestcache Update Cache

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/aspx/

Postupdaterequestcache has updated the cache

The log operation requested by logrequest

Postlogrequest has completed the requested log operation

EndRequest This is the end of this request

The first event to be triggered is beginrequest, which marks the beginning of the server process and the first event the programmer can handle in asp.net for the request.

Once the request is processed, the first task is to authenticate the user to implement the security mechanism, which is handled through the AuthenticateRequest and postauthenticaterequest two events. Obviously authenticaterequest means to start checking the user's identity, while Postauthenticaterequest indicates that the validation is complete.

When ASP.net obtains the user's identity, according to the current user's identity, starts the request permission the examination work, when fourth event authorizerequest triggers, expresses carries on the user authority the inspection work, but the fifth event then marked completes the user authority inspection work, if the user did not pass the security check, under normal circumstances , the remaining events are skipped, triggering the last event end processing directly.

When the user obtains the requested permission, the server begins to prepare the fastest way to be the result of the user's response, and the Resolverequestcache event signals a check cache to see if the results can be directly obtained from the previous cached results. The Postresolverequestcache represents the end of the cache check.

When a result cannot be obtained from the cache, the result of the current request must be evaluated through a single process, in. NET, the object that is used to process the request to get the result is called the processing object handler, there are many handlers in the asp,net, and the programmer can customize the handler, To handle this request, ASP. NET must follow the matching rule to find a processing of the current plea, Postmaprequesthandler event flag asp.net has obtained the handler object, HttpContext handler represents this processing object.

When you get the handler, you can't start processing immediately, because processing the request also requires a lot of data related to the request, such as the data we keep on the server about the user, so the session appears, and he provides the state management based on conversation.

In order to obtain data previously saved by the user, the Acrequirerequeststate event provides a point of entry for the programmer, Postacrequirerequeststate indicates that the user's data should be obtained and can be used in processing.

Now the next thing we're going to do is prerequesthandlerexcute really started telling programmers that the process is starting to work. If the user's status has been acquired and there is work to be done before the handler is processed, start in the event.

After the Prerequesthandlerexcute event, the ASP. NET Server will perform the processing of the request by executing the handler, which may be a Web form or a Web service.

When the handler is finished, the server starts to mop up, Postrequesthandlerexcute notifies the programmer, ASP. NET server has finished processing.

After processing is completed, because the user may modify user-specific data in the handler, the modified user state data may need to be serialized and saved, and the ReleaseRequestState event notifies the programmer to release the data. Postreleaserequeststate indicates that the release has been completed.

After processing is complete, if you want to cache the results of this process so that you can use this result directly in subsequent requests, Updaterequestcache provides an opportunity to process, Postupdaterequestcache indicates that the cache has been updated. The last section is over.

---Recovery content is over---

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.