Asp.net mvc 行动结果是什么?

Asp.net mvc 行动结果是什么?,asp.net-mvc,asp.net-mvc-3,Asp.net Mvc,Asp.net Mvc 3,据我所知,它是一个可以返回视图的类 因为在某些动作的基础上,我试图执行一个视图 请确认它是否正确。是 Encapsulates the result of an action method and is used to perform a framework-level operation on behalf of the action method. 是的 Encapsulates the result of an action method and is used to perform a

据我所知,它是一个可以返回视图的类 因为在某些动作的基础上,我试图执行一个视图

请确认它是否正确。

Encapsulates the result of an action method and is used to perform a framework-level operation on behalf of the action method.
是的

Encapsulates the result of an action method and is used to perform a framework-level operation on behalf of the action method.

ActionResult
是各种结果的基类,可以从操作方法返回。它不一定是一个视图。行动结果可能是什么,有很多选择:

  • ContentResult
    -用户定义的内容
  • EmptyResult
    -仅为空
  • FileResult
    -二进制文件
  • HttpStatusCodeResult
    -特定的HTTP响应状态代码和说明
  • JavaScriptResult
    -js代码
  • JsonResult
    -格式化为JSON的数据
  • 重定向结果
    -重定向到url
  • RedirectToRouteResult
    -重定向到某个MVC路由
  • ViewResult
    -这实际上就是视图
  • 局部视图
    -局部视图
在大多数示例中,您将其视为操作的返回值的原因是:

public ActionResult MyAction()
{
    if(someCondition)
       return View();  // return the view from action
    else
       return RedirectToAction("SomeOtherAction","OnSomeOtherController"); // redirect to other action 
}

ActionResult
是各种结果的基类,可以从操作方法返回。它不一定是一个视图。行动结果可能是什么,有很多选择:

  • ContentResult
    -用户定义的内容
  • EmptyResult
    -仅为空
  • FileResult
    -二进制文件
  • HttpStatusCodeResult
    -特定的HTTP响应状态代码和说明
  • JavaScriptResult
    -js代码
  • JsonResult
    -格式化为JSON的数据
  • 重定向结果
    -重定向到url
  • RedirectToRouteResult
    -重定向到某个MVC路由
  • ViewResult
    -这实际上就是视图
  • 局部视图
    -局部视图
在大多数示例中,您将其视为操作的返回值的原因是:

public ActionResult MyAction()
{
    if(someCondition)
       return View();  // return the view from action
    else
       return RedirectToAction("SomeOtherAction","OnSomeOtherController"); // redirect to other action 
}