ASP. NET Web API VS ASP. NET MVC

Source: Internet
Author: User
Tags hosting

Http://www.dotnet-tricks.com/Tutorial/webapi/Y95G050413-Difference-between-ASP.NET-MVC-and-ASP.NET-Web-API.html

    • ASP. Used to create Web applications. Returns both views and data, but ASP. Web API is used to create full Blown HTTP services with easy and simple to returns only data not view. (ASP MVC returns the view and data, and the ASP. NET Web API returns only)

    • Web API helps to build rest-ful services over the. NET Framework and it also support content-negotiation (it's about Decidi NG the best response format data that could is acceptable by the client. It could is json,xml,atom or other formatted data), the self hosting which is not in MVC. (Web APIs in different forms, such as Xml,json, etc.)

    • Web API also takes care of returning data in particular format like Json,xml or any other based upon the Accept header in The request and you don ' t worry on that. MVC only returns the data in JSON format using Jsonresult. (MVC can only return JSON type)

    • In Web API the request was mapped to the actions based on HTTP verbs and in MVC it was mapped to actions name. (HTTP for Web API Request maps to a specific action based on a predicate, and MVC maps to a specific action based on the action name)

    • The ASP. NET Web API is a new framework and part of the core ASP. The model binding, filters, Routing and others MVC features exist in Web API is different from MVC and exists in the new System.Web.HttpAssembly. In MVC, these featues exist with in System.Web.Mvc . Hence Web API can also is used with ASP. And as a stand alone service layer. (ASP Web API features such as model binding, filters, Routing is implemented in System.Web.Http, and the functionality of a similar MVC framework is implemented in SYSTEM.WEB.MVC. This means that the Web API and ASP MVC are two separate systems.

    • You can mix Web APIs and MVC controller in a single project to handle advanced AJAX requests which may return data in JSON, XML or any others the format and building a full blown HTTP service. Typically, this would be the called Web API self hosting. (You can use Web APIs and MVC in the same project)

    • When you had mixed MVC and Web API controller and want to implement, the authorization then you had to create the FIL Ters one for MVC and another for Web API since boths is different. (If you mix Web API controllers and MVC controllers together, they need autho Rization, you have to implement the respective authorization mechanism)

    • Moreover, web API is light weight architecture and except the Web application it can also being used with smart phone apps. (W EB API is a lightweight architecture that can be used in mobile programs)

ASP. NET Web API VS ASP. NET MVC

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.