Actionresult vs JSONresult
我有两个问题:
What is the difference between JSONResult and ActionResult?
When to use JSONResult in MVC?
号
您应该将您的操作方法声明为返回
当您希望返回客户机(网页或移动客户机上的javascript)使用的原始JSON数据时,请使用
如果您想返回一个由浏览器处理的视图、重定向等,请使用
JsonResult
This one is a bit more complex, but still not very. It also has
hardcoded its ContentType, but what makes it a bit more complex is
that it uses a hardcoded JavaScriptSerializer to serialize the JSON
data before writing it directly to the response.
号
这篇文章很有帮助http://brendan.enrick.com/post/types-of-aspnet-mvc-3-action-results.aspx
根据
The ActionResult class Encapsulates the result of an action method and
is used to perform a framework-level operation on behalf of the action
method.An action method responds to user input by performing work and
returning an action result. An action result represents a command that
the framework will perform on behalf of the action method. The
ActionResult class is the base class for action results
号
对于jsonresult:
Represents a class that is used to send JSON-formatted content to the
response.
号