Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC4 Web API or MVC3 JsonResult

I've seen a lot of arguments for why moving from WCF to Web API is a good move, but I haven't seen much on migrating from a controller with JsonResult actions to a Web API project. Can anyone provide the main benefits on switching to the Web API platform, or does it make sense to not migrate and stay on MVC3?

like image 852
Shawn Hubbard Avatar asked Jun 19 '12 00:06

Shawn Hubbard


1 Answers

WebAPI provides a lot of stuff out of the box that you don't get with a standard JsonResult. For instance, WebAPI is aware of the content types the caller expects, and can return Json, or XML or other types as requested.

Another nice feature is that WebAPI is oData aware, and you can use standard oData HTTP commands to filter and perform other actions, all without your code needing to do anything specific.

WebAPI has tons of nifty features that make a nice webservice, without the overhead of a full WCF service or asmx.

If you're happy with a JsonResult though, there's no need to rewrite it.

like image 191
Erik Funkenbusch Avatar answered Oct 11 '22 02:10

Erik Funkenbusch