相关疑难解决方法(0)

何时使用JsonResult而不是ActionResult

我一直无法找到关于这个问题的具体答案.我已经查看了这个问题以及其他地方的帖子和后续帖子,但我真正读到的只是JsonResult有一个硬编码的内容类型,并且确实没有任何性能提升.

如果两个结果都可以返回Json,为什么需要在ActionResult上使用JsonResult.

public ActionResult()
{
    return Json(foo)
}

public JsonResult()
{
    return Json(bar)
}
Run Code Online (Sandbox Code Playgroud)

任何人都可以解释ActionResult无法完成工作并且必须使用JsonResult的情况.如果没有,为什么JsonResult首先存在.

c# asp.net-mvc json return-value asp.net-mvc-4

22
推荐指数
1
解决办法
2万
查看次数

标签 统计

asp.net-mvc ×1

asp.net-mvc-4 ×1

c# ×1

json ×1

return-value ×1