差的ViewResult()和的ActionResult()之间 [英] Difference Between ViewResult() and ActionResult()
问题描述
是什么在ASP.NET MVC 的ViewResult()
和的ActionResult()
之间的区别?
公开的ViewResult指数()
{
返回查看();
}公众的ActionResult指数()
{
返回查看();
}
的ActionResult是,可以有几种亚型的抽象类。
的ActionResult亚型
-
的ViewResult - 渲染一个specifed以响应流
-
PartialViewResult - 渲染一个specifed局部视图响应流
-
EmptyResult - 返回一个空的响应
-
RedirectResult - 执行一个HTTP重定向到URL specifed
-
RedirectToRouteResult - 执行一个HTTP重定向到被确定的网址
路由引擎,根据给定数据路由 -
JsonResult - 序列化一个给定的ViewData对象来JSON格式
-
JavaScriptResult - 返回一段JavaScript代码code,可以在客户端上执行
-
ContentResult类型 - 内容写入到响应流,而不需要一个视图
-
FileContentResult - 返回一个文件到客户端
-
FileStreamResult - 返回文件到客户端,这是由流提供
-
FilePathResult - 返回一个文件到客户端
资源
- 什么行动方法的ActionResult和的ViewResult的区别的 [ASP.NET论坛]
?
What is the difference between ViewResult()
and ActionResult()
in ASP.NET MVC?
public ViewResult Index()
{
return View();
}
public ActionResult Index()
{
return View();
}
ActionResult is an abstract class that can have several subtypes.
ActionResult Subtypes
ViewResult - Renders a specifed view to the response stream
PartialViewResult - Renders a specifed partial view to the response stream
EmptyResult - An empty response is returned
RedirectResult - Performs an HTTP redirection to a specifed URL
RedirectToRouteResult - Performs an HTTP redirection to a URL that is determined by the routing engine, based on given route data
JsonResult - Serializes a given ViewData object to JSON format
JavaScriptResult - Returns a piece of JavaScript code that can be executed on the client
ContentResult - Writes content to the response stream without requiring a view
FileContentResult - Returns a file to the client
FileStreamResult - Returns a file to the client, which is provided by a Stream
FilePathResult - Returns a file to the client
Resources
这篇关于差的ViewResult()和的ActionResult()之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!