ASP.NET MVC中的ActionResult--总结
Ø ActionResult及其子类的对照表
ActionResult的子类名称 |
说明 |
ViewResult |
表示HTML的页面内容 |
EmptyResult |
表示空白的页面内容 |
RedirectResult |
表示定位到另外一个URL |
JsonResult |
表示可以运用到AJAX程序中JSON结果 |
JavaScriptResult |
表示一个JavaScript对象 |
ContentResult |
表示一个文本内容 |
FileContentResult |
表示一个可以下载的、二进制内容的文件 |
FilePathResult |
表示一个可以下载的、指定路径的文件 |
FileStreamResult |
表示一个可以下载的、流式的文件 |
通过我们在代码中编写,不难看到如下的一段代码:
public ActionResult Index()
{
return View();
}
可能有人会有疑问,既然我定义的是ActionResult,为什么返回值会是View呢?
其实这个View的类型是ActionResult的子类ViewResult,有关Controller中的方法与返回对象请参照下表:
Controller中的方法 |
返回对象 |
View |
ViewResult |
Redirect |
RedirectResult |
RedirectToAction |
RedirectToActionResult |
RedirectToRoute |
RedirectToRouteResult |
Json |
JsonResult |
JavaScriptResult |
JavaScriptResult |
Content |
ContentResult |
File |
FileContentResult、FilePathResult、FileStreamResult
|
转载于:https://www.cnblogs.com/CskyWarrior/p/4989333.html
- 点赞
- 收藏
- 分享
- 文章举报
- ASP.NET MVC中常用的ActionResult类型
- 了解ASP.NET MVC几种ActionResult的本质:EmptyResult & ContentResult
- ASP.NET MVC ActionResult一些常用的子类
- ASP.NET MVC ActionResult的实现
- Asp.Net MVC中不指定View Name时如何返回ActionResult的
- Asp.net Mvc Action重定向总结
- 理解ASP.NET MVC中的ActionResult [转 深山老林]
- ASP.NET MVC中常用的ActionResult类型
- asp.net mvc之ActionResult
- [转载]深入理解ASP.NET MVC之ActionResult
- 了解ASP.NET MVC几种ActionResult的本质:FileResult
- 了解ASP.NET MVC几种ActionResult的本质:EmptyResult & ContentResult
- ASP.NET MVC学习笔记-Controller的ActionResult
- Asp.net MVC 中Controller返回值类型ActionResult
- 了解ASP.NET MVC几种ActionResult的本质:JavaScriptResult & JsonResult
- ASP.NET MVC 不同的 ActionResult 小示例
- 了解ASP.NET MVC几种ActionResult的本质:EmptyResult & ContentResult
- 了解ASP.NET MVC几种ActionResult的本质:JavaScriptResult & JsonResult
- ASP.NET MVC中ActionResult返回值
- ASP.NET MVC ActionResult的其它返回值