ASP.NET Core HTTP attributes
According to the Internet Engineering Task Force (IETF) RFC-7231 document (https://tools.ietf.org/html/rfc7231), ASP.NET Core has implemented seven HTTP attributes out of the eight HTTP verbs listed. The only exclusion in the framework, from the list of verbs, is the HTTP TRACE verb.
Following is the complete list of HTTP verb attributes that are provided in ASP.NET Core:
- HttpGetAttribute
- HttpPostAttribute
- HttpPutAttribute
- HttpDeleteAttribute
- HttpHeadAttribute
- HttpPatchAttribute
- HttpOptionsAttribute
As the verb name is attached with the attribute, it is very obvious that they will be used for their respective verbs. These attributes help the framework to understand what action method is associated with what verb. With that in mind, it can decide which one to execute when a request comes for the controller.
Another important attribute for routing is also provided by the framework, named RouteAttribute.
There are a few more attributes used for the parameters of action methods to help recognize parameters passed to the API action from different places of the request such as URL, Body, and so on. Following are some attributes present in the framework for the action parameters:
- FromServicesAttribute
- FromRouteAttribute
- FromQueryAttribute
- FromBodyAttribute
- FromFormAttribute