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

I am creating an ASP.NET MVC application and still consider myself new to ASP.NET MVC. I came from the WCF REST background, so I initially set up a number of services that my jQuery client will call through RESTful AJAX requests. Since I learned more about ASP.NET MVC, I discovered the JSONRESult ActionResult type, and I can just add these methods to the controller, and it behaves the same as my WCF RESTful services.

So my question is: is there a JsonResults restriction that I don't see what WCF RESTful services provide? So far I have not seen this and am wondering if this completely eliminates the need to use WCF REST functions.

Thanks in advance!

+4
source share
3 answers

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

ASP.Net MVC is for HTTP only. REST no. Representative state transfer or REST, while most often defined via HTTP, is not limited to HTTP . WCF allows you to communicate through non-HTTP connections.

In addition, I agree that it is easier and more reliable to implement REST in MVC and especially in the new MVC Web API materials, but this suggests that REST also takes place in WCF, since WCF can stand on it without HTTP.

EDIT: It should also be noted that WCF can work independently without IIS.

+1
source

Not everyone builds ASP.NET MVC applications .... not everyone even builds ASP.NET in any form.

WCF REST is a service technology that is completely independent of ASP.NET or the Internet — you can have WCF REST services without IIS.

+2
source

Although technically true that REST! = HTTP, most REST services use HTTP. And Microsoft is integrating its WCF HTTP / REST stack into ASP.Net. Check this page from the WCF codeplex website:

http://wcf.codeplex.com/wikipage?title=WCF%20HTTP

And this page

http://wcf.codeplex.com/discussions/319671

This means that if you want the latest HTTP REST support, you should definitely upgrade to the new ASP.Net web interface that ships with ASP.Net MVC 4.

Using this approach, your services can run in IIS (obviously), but can also be hosted if you want.

Also, if you have any investment in WIF with your external WCF services (for example, custom authentication / authorization classes, custom token handlers, etc.), they can easily be moved from WCF to ASP.Net.

Finally, MVC 4 is open source and participatory, so it will be fast and of high quality, and the risk of MS leaving you stuck with termination is much less.

+1
source

Source: https://habr.com/ru/post/1344619/


All Articles