Asp. Net Web api vs Asp. Net MVC, apimvc

Source: Internet
Author: User

Asp. Net Web api vs Asp. Net MVC, apimvc

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

  • Asp. net MVC is used to create web applications that returns both views and data but Asp. net Web API is used to create full blown HTTP services with easy and simple way that returns only data not view. (asp mvc returns view and data, Asp. net Web API only returns data)

 

  • Web API helps to build REST-ful services over. NET Framework and it also support content-negotiation (it's about deciding the best response format data that cocould be acceptable by the client. it cocould be JSON, XML, ATOM or other formatted data), self hosting which are not in MVC. (data in different forms of Web APIs, such as xml and json)

 

  • Web API also takes care of returning data in particle format like JSON, XML or any other based upon the Accept header in the request and you don't worry about that. MVC only return data in JSON format using JsonResult. (MVC can only return json data)

 

  • In Web API the request is mapped to the actions based on HTTP verbs but in MVC it is mapped to actions name. (the http request of Web API is mapped to a specific action based on the predicate, while MVC maps the request to a specific action based on the action name)

 

  • Asp. net Web API is new framework and part of the core ASP. NET framework. the model binding, filters, routing and others MVC features exist in Web API are different from MVC and exists in the newSystem.Web.HttpAssembly. In MVC, these featues exist with inSystem.Web.Mvc. Hence Web API can also be used with Asp. net and as a stand alone service layer. (various functions of ASP Web APIs, such as model binding, filters, and routing, are stored in the System. web. http. web. implemented in Mvc. That is to say, Web API and Asp MVC are two independent systems)

 

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

 

  • When you have mixed MVC and Web API controller and you want to implement the authorization then you have to create two filters one for MVC and another for Web API since boths are different. (if you use Web API controller and MVC controller together, you must implement their respective authorization mechanisms when they need authorization)

 

  • Moreover, Web API is light weight architecture and plugin t the web application it can also be used with smart phone apps. (Web API is a lightweight architecture and can be used in mobile apps)

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.