MVC4的Web API或MVC3 JsonResult [英] MVC4 Web API or MVC3 JsonResult

查看:123
本文介绍了MVC4的Web API或MVC3 JsonResult的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了,为什么从WCF移动到网页API是一个很好的举措不少争论,但我还没有看到太多关于从JsonResult动作到Web API项目控制器迁移。任何人都可以提供切换到Web API平台的主要好处,或者是否有意义不迁移,留在MVC3?

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?

推荐答案

的WebAPI提供了很多的东西出来,你不使用标准的JsonResult得到箱。例如,的WebAPI知道呼叫者期望的内容类型的,并且可以返回JSON或XML或其他类型的请求。

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.

另一个优点是,是的WebAPI的OData知道,你可以使用标准的HTTP OData的命令来过滤和执行其他操作,都没有你的code需要做具体的事情。

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拥有吨漂亮的功能,使一个很好的web服务,没有一个完整的WCF服务或ASMX的开销。

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

如果你很高兴与JsonResult不过,没有必要重写一遍。

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

这篇关于MVC4的Web API或MVC3 JsonResult的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆