Search code examples
wcfasp.net-mvc-2wcf-rest

Why use WCF REST when you have JsonResult in ASP.NET MVC?


I'm building an ASP.NET MVC application and still consider myself new to ASP.NET MVC. I come from a WCF REST background, so I initially set up a number of services that my jQuery-based client would call via RESTful AJAX requests. As I learned more about ASP.NET MVC, I discovered the JsonResult ActionResult type, and I can just add these methods to a controller and it behaves just like my WCF RESTful services.

So my question is, is there a limitation to JsonResults that I'm not seeing that WCF RESTful services provides? So far, I haven't seen it and am wondering if this completely eliminates my need for WCF REST functionality.

Thanks in advance!


Solution

  • In your case, I'd go with MVC for my REST implementation, but to answer your question:

    MVC ASP.Net is built to be HTTP only. REST is not. Representational State Transfer, or REST, while most commonly defined over HTTP, is not limited to HTTP. WCF allows you to communicate over non-HTTP connections.

    Outside of that, I'd agree that it's easier and more robust to implement REST in MVC and especially in the newer MVC Web API stuff, but that said, REST has its place in WCF as well, because WCF can stand on it's own without HTTP.

    EDIT: Also it should be noted that WCF can stand on it's own without IIS.