ASP. NET web API processing architecture

Source: Internet
Author: User
Tags web hosting

This articleArticleThis section mainly introduces the processing architecture of ASP. NET Web APIs: the process when an HTTP request arrives until a request is generated. The processing architecture of ASP. NET Web APIs is as follows, which consists of three layers: hosting, message handler pipeline, and controller handling ).

 

Host)

The underlying layer is responsible for the hosting of Web APIs, interfaces between Web APIs, and HTTP Processing engines. In a word, this layer is responsible for creating an httprequestmessage instance. Then they are pushed to the upper-layer message processing pipeline. The host layer is also responsible for the httpresponsemessage returned by the message processing pipeline. Currently, there are two built-in host options in ASP. NET Web APIs: Self-hosting and web hosting. Web Hosting is also the host in the processing pipeline of Asp.net in IIS,Self-hostingIt is a WCF message instance based on the WCF channel stack, which is then converted to the httprequestmessage instance and pushed to the upper-layer message processing pipeline.Web-hostingIt is based on ihttpasynchandler and named httpcontrollerhandler. It converts httprequest to httprequestmessage. Of course, web API hosting is scalable and not limited to these two options. You can customize it as needed,CommunitySomeone has implemented a third-party host Louis Dejardin in owin created a host.

Message handler Pipeline)

The middle layer is message handler pipeline, which is the content of the WCF web API. It is exposed through the httpserver class, and it also extends httpmessagehandler. This pipeline provides various extensions of the intermediate layer (addressing cross-cutting concerns) such as logs, HTTP verification ,......

Usually at the top of this pipeline is a special processor: httpcontrollerdispatcher. This processor is responsible for obtaining and calling a controller to process requests. Httpcontrollerdispatcher is used only when the controller-based programming model (the derived class of apicontroller) is used, or a completely different model can be used, you only need to replace the top message processor.

Controller handling)

Finally, the upper-layer controller processes the related processes, namely:

    • Action selection;
    • Filter execution;
    • Model binding;
    • Action invocation;
    • Response content creation via formatters.

These processes are all completed in the apicontroller instance and called by httpcontrollerdispatcher.

The process above is still very clear. This article only briefly introduces the entire process, and the subsequent articles detail each part.

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.