ASP. NET Web API Routing (top)

Source: Internet
Author: User

1 What is ASP. NET Web API Routing

ASP. NET Web routing is actually an abstract message processing pipeline, and the ASP. NET Web API's routing mechanism differs from the ASP. NET routing mechanism, but it has a similar set of designs to the ASP.

2 related objects for ASP. NET Web API requests and responses

The request for the ASP. NET Web API is to process the requested message through Htpprequestmessage as a pipeline and to process the response message through Htppreponsemessage as a pipe. That is, the ASP. NET WEB API handles user requests and responds to user's core objects are httprequestmessage and Htppreponsemessage, and ASP. HttpRequest and Httpreponse are used to process user requests and responses.

2.1 Httprequestmessage Object

In a complete HTTP request/Response message is composed of the starting line, header collection, the main content of the three parts.

The start line in HTTP contains the HTTP method, the request URI, the HTTP version, and the starting line property in Httprequestmessage is method, RequestUri, and vesion.

HTTP Httprequestmessage
HTTP method Method
Request URI RequestUri
HTTP version Vesion

In the request message header collection, the main content in the httprequestmessage embodiment is headers, content respectively.

Note: If we do not set the HTTP method, the Httprequestmessage default is to use the get

2.2 Htppreponsemessage Object

In the ASP. NET Web API, the response message is represented by the Htppreponsemessage type, where information about the HTTP response messages can be obtained. The starting line of the HTTP response message contains the HTTP version, the response status code, and the status text description related information, which corresponds to the version, Statucode, and Reasonphrase attributes, respectively, in the Htppreponsemessage.

HTTP Htppreponsemessage
HTTP version Version
Response Status Code Statucode
Status text description Reasonphrase

In the response message of the header set, the main content of the htppreponsemessage embodiment is headers, content.

2.3 Httpcontent Object

In Httprequestmessage and Htppreponsemessage, there is another property of type Httpcontent, which is used to represent the principal content of the request message and the response header. There is a read-only property in httpcontent headers can get a httpcontentheaders that can be used to obtain the relevant header of the request/corresponding message's principal content.

Note: Httpcontentheaders represents a number of headers that can be viewed in the MSDN documentation Httpcontentheaders Class

ASP. NET Web API routing (top)

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.