RESTful service in .net - which is better choice WCF or ASP.NET MVC?

1.4k views Asked by At

I plan to write web app which will work mostly on client side (AJAX) and RESTfully communicate with server using JSON and have another client which will use XML (or eventually JSON too). This app will have client authentication but is rather simple and small.

Which is better choice for this RESTfully web service: WCF or ASP.NET MVC?

2

There are 2 answers

1
Tom Chantler On BEST ANSWER

The right answer is probably: It depends.

If you're already familiar with one of the technologies, then maybe you should use that one, but I'd rather use ASP.NET MVC.

I am now going to mention two articles by Omar Al Zabir

If you want to go down the ASP.NET MVC route then read this: http://www.codeproject.com/Articles/233572/Build-truly-RESTful-API-and-website-using-same-ASP

If you're going to use WCF then read this about improving scalability: http://www.codeproject.com/Articles/234085/Fixing-WCF-to-build-highly-scalable-async-REST-API

The cool thing about using MVC is that you can write a RESTful app and expose a RESTful API all with the same code.

EDIT: Just to clarify, the MVC RESTful project DOES support GET, PUT, POST, DELETE, so it really is truly RESTful. See the documentation here: http://code.msdn.microsoft.com/Build-truly-RESTful-API-194a6253

specifically this bit:

All these URLs support GET, POST, PUT, DELETE. Users can browse to these URLs and get html page rendered. Client apps can make AJAX calls to these URLs to perform CRUD on these. Thus making a truly RESTful API and website.

6
Richard Blewett On

At this point, if you are starting a project now I would head down the WCF WebAPI route. MVC provides the basic infrastructure for building a REST API but doesn't have built in support for things like content type negotiation.

The WebAPI is intended to provide first class support for REST style services for the .NET framework

However, the Web API hasn't yet been released (although I'm pretty sure it will be this year) so you will be developing on beta code - oh and its also available on Nuget

btw - the CHM file has some good stuff in it to get you started