ASP. NET Web API VS ASP. NET MVC
1. ASP. NET MVC is a Web application that creates a return view (views) and data, and the ASP. NET Web API is a simple and easy-to-mature HTTP service that returns only data and does not return views.
2. The ASP. NET Web API can help us build the rest-ful service through the, and he supports content negotiation (which returns the appropriate json,xml,atom based on the format requirements that the client can accept), while the ASP. The API supports self-hosting (self-hosting), which MVC does not support (only hosted in IIS).
3. The ASP. NET Web API can return specific data types, such as Json,xml, or other data formats defined in the request header. MVC can only use JSON result to return the JSON data type.
4. The ASP. NET Web API maps an action based on an HTTP predicate verb, but MVC simply maps the action name.
5. The ASP. NET Web API is a new framework that is part of the ASP. NET Framework Core Library. Some of the features that exist in MVC (model binding, filters, routing) exist in the ASP. System.Web.Http assembly, and MVC is present in SYSTEM.WEB.MVC. Therefore, the Web API can be used in conjunction with ASP, or it can be a separate service layer.
6. If you are merging Web APIs and MVC controllers in a project to handle complex AJAX requests, these requests may return json,xml or other data formats. This is the Web API self-hosted (Web API self-hosting).
7. If you are merging MVC and Web API controllers (Controller) and require integrated authentication, then you need to create two filters (Filters), one MVC, another Web API, because the two of them are not the same.
8. In short, Webapi is a lighter-weight architecture than MVC in providing data.
ASP. NET MVC differs from ASP. NET Web API