加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – Actionresult vs JSONresult

发布时间:2020-12-15 18:45:58 所属栏目:asp.Net 来源:网络整理
导读:我有2个问题: What is the difference between JSONResult and ActionResult? When to use JSONResult in MVC? 解决方法 ActionResult是一个动作可以返回的抽象类。 Controller中的帮助方法(例如Json(),Content(),View(),…)返回不同的继承ActionResult
我有2个问题:
  1. What is the difference between JSONResult and ActionResult?

  2. When to use JSONResult in MVC?

解决方法

ActionResult是一个动作可以返回的抽象类。

Controller中的帮助方法(例如Json(),Content(),View(),…)返回不同的继承ActionResult的具体类,包括JsonResult。

您应该将您的操作方法声明为返回ActionResult,以便他们可以自由返回任何具体的结果类。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读