Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Web API vs ASP.NET MVC JSON web services [closed]

Tags:

What is the advantage of using new WCF Web API over ASP.NET MVC 3 to expose a lightweight JSON Web service layer? I like Web API in many ways, but the drawback is that it doesnt work on mono, while MVC 3 does. What are the major differences between the two approaches?

like image 311
adrin Avatar asked May 01 '11 11:05

adrin


People also ask

What is the difference between Web API and Web Service and WCF?

WCF offers supports for limited RESTFUL service. WEB API is ideal for building RESTFUL services. Web API can be configured using web. config service.

Is ASP Net Web API closer to REST than WCF?

Web API has very less configuration when compared to wcf and is bit faster than wcf. Wcf also supports restful services. If you have limitation of . Net framework 3.5 then your option is wcf.

Which is better WCF or Web API?

WEB API is a better choice for simpler, light weight services. WEB API can use any text format including XML and is faster than WCF. WEB API can be used to create full-blown REST Services. WEB API doesn't require any data contracts and doesn't require configurations to the level of WCF.

Which is better Web API or MVC?

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.


2 Answers

It is recognized by Microsoft, that there is some overlap between the two products. However, they do have a different focus:

  • If you are building a web site that consumes JSON from your web service then MVC is probably the best choice.

  • If you are building an API intended to be consumed by a variety of third party clients then WCF Web API is the best choice.

My own personal reasons include the fact that with WCF Web API means I can self-host in a Windows service, and I can avoid ASP.NET, web.config and Cassini :-)

like image 158
Darrel Miller Avatar answered Sep 28 '22 21:09

Darrel Miller


Updated 6/24/14 by request:

What is now ASP.NET Web API (formerly WCF Web API) and ASP.NET MVC will formally merge in what is currently dubbed ASP.NET vNext (MVC 6).

http://www.asp.net/vnext/overview/aspnet-vnext/overview

===========================================================================

Original answer:

It was announced yesterday (2/8/2012) that the projects are formally merging. See:

http://www.c4mvc.net/meeting/?id=25

and

http://msdn.microsoft.com/en-us/hh824721

The c4mvc link should be updated with a link to Dan Roth's presentation soon.

like image 30
David Peden Avatar answered Sep 28 '22 20:09

David Peden