In-depth analysis of ASP. NET Core pipelines [4] and core analysis

Source: Internet
Author: User
Tags webhost

In-depth analysis of ASP. NET Core pipelines [4] and core analysis

The reason why ASP. NET Core is called a Web development platform is that it has a highly scalable request processing pipeline. We can customize this pipeline to meet HTTP processing needs in various scenarios. Many features of ASP. NET Core applications, such as routing, authentication, session, cache, and so on, are also customized to implement the message processing pipeline. We can even use pipelines to create our own Web framework on the ASP. NET Core platform. In fact, the two important Web frameworks MVC and SingalR are also created in this way.

1. Use pipelines to process HTTP requests

The characteristics of the HTTP protocol determine that the way any Web application works is to listen, receive, and process HTTP requests, and finally respond to the requests, HTTP request processing is a typical scenario of pipeline design. We have customized A Message Processing Pipeline Based on the processing process of the HTTP request, so that the received HTTP request messages can flow into the pipeline like water, each part of the pipeline is processed at a time. The processing result is also converted into a message reversely flowing into the pipeline for processing, and finally into an HTTP Response to the client. ASP. the message processing pipeline of NET Core is very simple from the design point of view, but it is relatively difficult to understand from the specific implementation point of view. In order to let readers have a deep understanding of this chapter, let's start with the simple section. [Read the full text]

 

2. Create a "mini version" pipeline to simulate the real pipeline request processing process

We know ASP. the NET Core request processing pipeline is composed of a server and a group of ordered middleware. Therefore, the overall design is very simple, but for specific implementation, because it involves the interaction of many objects, I think few people can figure it out. If you want to have a deep understanding of ASP. the request processing pipeline of NET Core can be carried out in two steps. First, we can clarify the overall process of pipeline processing HTTP requests while ignoring the details, and then add the missing details. To make it easier for readers to understand the overall process of pipeline processing HTTP requests, we create a "simulated Pipeline" Based on the implementation principle of the actual pipeline ". [Read the full text]

 

3. How does the MPs queue handle HTTP requests?

The ASP. NET Core request processing pipeline is composed of a server and a group of ordered middleware. On this basis, we can further abstract the latter into an HttpApplication object, then the pipeline becomes a combination of Server and HttpApplication (5 ). The Server forwards the received HTTP request to the HttpApplication object. The latter creates a context for the current request and processes the request in this context, after the request is processed and the response is complete, HttpApplication recycles and releases the context. [Read the full text]

 

4. How is an MPS queue created?

The request processing pipeline involves four core objects: WebHostBuilder, WebHost, Server, and HttpApplication. We use WebHostBuilder to create a WebHost and use the latter to construct a request processing pipeline.

The request processing pipeline is composed of a Server and an HttpApplication object, which encapsulates all registered middleware. When a WebHost is started, it creates the Server and HttpApplication objects and uses the latter as the parameter to call the Start method of the Server to Start the Server. The started Server enables listening requests and uses HttpApplication to process received requests. After HttpApplication completes all request processing, it uses the Server to complete the final response to the request. [Read the full text]

Reference page: http://qingqingquege.cnblogs.com/p/5933752.html

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.