Both the Sheng and the yoga? ASP. NET MVC VS ASP. NET Web API

Source: Internet
Author: User
Tags hosting

ASP. NET MVC differs from ASP. NET Web API

As we develop some Web applications, we can use Jsonresult in the MVC Framework to return JSON data, as well as to handle simple AJAX requests, so why is Microsoft launching a Web API like this? Next, let's compare. When are the two (ASP. NET MVC and ASP. NET Web APIs) used?

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.

Both the Sheng and the yoga? ASP. NET MVC VS ASP. NET Web API

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.