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)