views:

53

answers:

1

I want to be able to Ajax-ly retrieve JSON data from some kind of web service. (The web service calls will be wrapping a call to SQL, processing the DataSet returned, and returning a JSON representation.) Initially, I thought an ASP.NET MVC project with appropriately named Controllers and Actions that return JsonResults would suffice. However, a colleague suggested WCF might be a better fit for something like this. It's been my experience that WCF is difficult to configure; moreover, the way MVC exposes Actions through Controllers seems very elegant.

Which is a better fit for what I'm trying to do, MVC or WCF?

+6  A: 

If you're going to create services that create strictly JSON (with no other end-points on the horizon), I find that .NET MVC is much easier to use and produces better results.

If you think you might want multiple types of end-points (SOAP, etc.) at some point in the future, then go with WCF.

Keep in mind that there are rumblings from the WCF team that they are about to release something that will completely overhaul how RESTful JSON services in WCF are done. It should be interesting.

Justin Niessner
I will keep that in mind thanks! Good answer :)
Pwninstein
"produces better results" can you clarify? Do you mean overall or the quality of the JSON?
jfar
@jfar - I was thinking about the size of the JSON results (poorly worded in the answer though). WCF includes type hinting which can add a lot of "unnecessary" overhead in the JSON response for large nested collections.
Justin Niessner