据我了解,它是一个可以返回视图的类,因为基于某些操作,我正在尝试执行视图。
请确认它是正确的。
ActionResult是各种结果的基类,可以从操作方法返回。它不一定是一个视图。动作结果可能有很多选择:
ContentResult- 用户定义的内容EmptyResult- 只是空的FileResult- 二进制文件HttpStatusCodeResult- 具体的 HTTP 响应状态码和描述JavaScriptResult- js代码JsonResult- 数据格式为 JSONRedirectResult- 重定向到网址RedirectToRouteResult- 重定向到一些 MVC 路由ViewResult- 这实际上是视图PartialView- 局部视图您在大多数示例中将其视为操作的返回值的原因是您可以:
public ActionResult MyAction()
{
if(someCondition)
return View(); // return the view from action
else
return RedirectToAction("SomeOtherAction","OnSomeOtherController"); // redirect to other action
}
是的
Encapsulates the result of an action method and is used to perform a framework-level operation on behalf of the action method.
http://msdn.microsoft.com/en-us/library/system.web.mvc.actionresult(v=vs.108).aspx