asp.net-mvc - Actionresult 与 JSONresult

标签 asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-mvc-5 jsonresult

我有两个问题:

  1. What is the difference between JSONResult and ActionResult?

  2. When to use JSONResult in MVC?

最佳答案

ActionResult是一个 Action 可以返回的抽象类。
Controller 中的辅助方法(例如, Json()Content()View() 、...)返回不同的继承 ActionResult 的具体类,包括 JsonResult .

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

关于asp.net-mvc - Actionresult 与 JSONresult,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15250941/

相关文章:

asp.net - ASP.NET MVC 5 中的自定义模型绑定(bind)器

c# - 我应该在哪里放置我的域模型以查看模型映射代码?

asp.net-mvc-3 - mvc3检测网站(应用程序)正在关闭

asp.net-mvc-3 - 如何将参数传递给 Ajax.ActionLink 的 Success 函数

jquery - 数据表和jsonresult的排序问题

c# - MVC 后模型 - 集合属性没有元素

c# - 时区策略

c# - 模型绑定(bind)到列表 MVC 4

javascript - JQuery 自动完成后获取 ID 的值

javascript - Kendo -MVC ListView - 如何获取所选行上的复选框状态(选中或未选中)