Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restful Webservices comparison WebAPI vs MVC

I was told to design an API for a client to manipulate some data. Now, trying to keep up with the Jones', I've designed this using WebAPI. I post to my Restful Webservice an object via $.Ajax

Why is this any different from using the same $.Ajax to post to a standard MVC 4.0 Controller?

What are the advantages?

Thanks

====

With regard to potential answer:

Note If you have worked with ASP.NET MVC, then you are already familiar with controllers. They work similarly in Web API, but controllers in Web API derive from the ApiController class instead of Controller class. The first major difference you will notice is that actions on Web API controllers do not return views, they return data.

====

Wouldn't this still be redundant, after all you can always

return JSON(x);

from any MVC controller.

like image 853
Pinch Avatar asked Apr 25 '13 19:04

Pinch


People also ask

What is the difference between MVC and REST API?

MVC is about how the inner side of your app works. REST is about how your app "talks" with other apps. You can combine them.

Which is better MVC or Web API?

The Web API returns the data in various formats, such as JSON, XML and other format based on the accept header of the request. But the MVC returns the data in the JSON format by using JSONResult. The Web API supports content negotiation, self hosting. All these are not supported by the MVC.

What is the difference between RESTful API and Web API?

1) Web API vs REST API: ProtocolWeb API supports protocol for HTTP/s protocol and URL requests/responses headers that enable services to reach various clients through the web. On the other hand, all communication in the REST API is supported only through HTTP protocol.

What is difference between MVC controller and Web API?

Differences between MVC (Model, View, Controller) and ASP.NET Web API are: MVC is for developing applications that return both data and views, while Web API only returns data using the HTTP services. They trace actions differently. Web API traces based on the HTTP service and MVC traces based on the action name.


1 Answers

http://encosia.com/asp-net-web-api-vs-asp-net-mvc-apis/

ASP.NET Web API vs. ASP.NET MVC “APIs” by Dave Ward --Thanks Ant P

A beautiful synopsis:

  • Content negotiation
  • Flexibility
  • Separation of concerns
like image 125
Pinch Avatar answered Sep 21 '22 17:09

Pinch