ASP. NET MVC 4 contains the ASP. NET Web API, a new framework for creating HTTP services that can connect multiple clients, including browsers, mobile devices and more, and the ASP. NET Web API is also the ideal platform for building RESTful services.
The ASP. NET Web API contains the following features:
- Advanced HTTP programming Model: Use the new strongly typed HTTP object model to manipulate HTTP requests and responses directly, using the same programming model and HTTP pipelines on HTTP clients;
- Support Routing: The Web API fully supports ASP. NET routing, including routing parameters and Constraints. In addition, to the Mapping Support Convention of the action, it is no longer necessary to add properties like [HttpPost] to the class or method;
- Content Negotiation: the client and the server can together determine the format of the API return data. By default, XML, JSON, and form url-encoded formats can be extended to add custom formats, and can even replace the default content negotiation policy;
- model Binding and validation: model Binders can easily extract data from an HTTP request and convert it to use in an action method. NET Object
- Filter: The Web API supports filtering, including the well-known [authorize] filtering tag, which allows you to add and insert custom filters for the Action, enabling authentication, exception handling, etc.
- Query aggregation: as long as you simply return iqueryable<t>, the Web API will support querying through OData address conventions;
- Improved HTTP detail testability: Instead of setting the HTTP details to a static Context object, the Web API uses Httprequestmessage and Httpresponsemessage instances to add custom types to these HTTP types using the generic versions of these objects ;
- improved dependency inversion (IoC) Support: The Web API uses the MVC Dependency Resolver implementation of the service locator pattern to get instances in different scenarios;
- code-based configuration: The Web API is configured separately using code to ensure the cleanliness of the configuration files;
- Self-hosting (self-host): The Web API, in addition to being hosted in IIS, can be hosted in a process and can still use routing and other features.
ASP. NET Web API features