的ActionResult VS JSONresult [英] Actionresult vs JSONresult
本文介绍了的ActionResult VS JSONresult的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个问题:
什么是JSONResult和ActionResult的区别?
当在MVC中使用JSONResult?
块引用>解决方案
的ActionResult
是一个抽象类,动作可以返回。在
控制器的辅助方法
(例如,JSON()
,内容()
,查看()
,...)返回继承的ActionResult
不同的具体类别,包括JsonResult
。您应声明动作方法为返回
的ActionResult
,让他们可以自由地返回任何具体成果类。I have 2 questions:
What is the difference between JSONResult and ActionResult?
When to use JSONResult in MVC?
解决方案
ActionResult
is an abstract class that an action can return.The helper methods in
Controller
(eg,Json()
,Content()
,View()
, ...) return different concrete classes that inheritActionResult
, includingJsonResult
.You should declare your action methods as returning
ActionResult
, so that they have the freedom to return any concrete result class.这篇关于的ActionResult VS JSONresult的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文