Asp. Net Web API (1), asp. netwebapi
What is Web API
HTTP is not only used for Web Pages. It is also a powerful platform for creating APIs that display services and data.HTTP is simple, flexible, and ubiquitous. You can imagine that almost any platform has an HTTP service library.HTTP services can involve a wide range of clients, including browsers, various mobile devices and traditional desktop applications.Web API provides a restful API development framework, which provides complete http semantic support.
Differences between Web APIs and MVC
1. Usage differences
MVC is mainly used for Web site development. It implements a complete MVC development framework on the backend to provide convenient page development and backend Html components, users can easily develop websites with pages
Web APIs are mainly used for Open API interfaces, which are more abstract and do not focus on VIew generation.
2. Differences in self-implementation
The two frameworks are mainly modified based on Asp. Net, and are mainly extended to HttpModule and HttpHandler.
MVC builds the second layer on the first layer, and extends a larger routing mechanism to implementMvcHandlerAndControllerFactoryThis message processing and background Controller method selection mechanism. In addition to extending the former, Web APIs also write a set of independent, independent of Asp. net message processing pipeline, just like drawing on the original house model and re-designing another villa, this also explains why Web APIs can be hosted on different hosts (in essence, the host uses a specific application to provide Web APIs to a runtime environment, and solve the request receipt and response), such as the Web Host and Self Host method, which is similar to that of WCF. MVC can only be hosted on IIS (. net core is not considered), just like WebForm. Besides, although both of them have controllers and actions, the request implementation and response mechanisms are also different. For example, the two core classes of Web API processing messages are HttpRequestMessage and HttpResponseMessage. These two frameworks can only be said to be similar in patterns at most, and there is a big difference in implementation.