在System.Web.Mvc命名空间
ActionResult
ContentResult
EmptyResult
FileResult
HttpStatusCodeResult
HttpNotFoundResult
HttpUnauthorizedResult
JavaScriptResult
JsonResult
RedirectResult
RedirectToRouteResult
ViewResultBase
PartialViewResult

ViewResult

示例代码:

public class ActionResultController : Controller

{

public ActionResult Index()

{

return View();

}

public ActionResult ContentResult()

{

return Content("Hi, 我是ContentResult结果");

}

public ActionResult EmptyResult()

{

//空结果当然是空白了!

//至于你信不信, 我反正信了

return new EmptyResult();

}

public ActionResult FileResult()

{

var imgPath = Server.MapPath("~/demo.jpg");

return File(imgPath, "application/x-jpg", "demo.jpg");

}

public ActionResult HttpNotFoundResult()

{

return HttpNotFound("Page Not Found");

}

public ActionResult HttpUnauthorizedResult()

{

//未验证时,跳转到Logon

return new HttpUnauthorizedResult();

}

public ActionResult JavaScriptResult()

{

string js = "alert(\"Hi, I'm JavaScript.\");";

return JavaScript(js);

}

public ActionResult JsonResult()

{

var jsonObj = new

{

Id = 1,

Name = "小铭",

Sex = "男",

Like = "足球"

};

return Json(jsonObj, JsonRequestBehavior.AllowGet);

}

public ActionResult RedirectResult()

{

return Redirect("~/demo.jpg");

}

public ActionResult RedirectToRouteResult()

{

return RedirectToRoute(new {

controller = "Hello", action = ""

});

}

public ActionResult ViewResult()

{

return View();

}

public ActionResult PartialViewResult()

{

return PartialView();

}

//禁止直接访问的ChildAction

[ChildActionOnly]

public ActionResult ChildAction()

{

return PartialView();

}

//正确使用ChildAction

public ActionResult UsingChildAction()

{

return View();

}

}

转载于:https://www.cnblogs.com/q149072205/archive/2012/03/21/2409810.html

(转)ASP.NET MVC3默认提供了11种ActionResult的实现相关推荐

  1. 聊聊ASP.NET Core默认提供的这个跨平台的服务器——KestrelServer

    跨平台是ASP.NET Core一个显著的特性,而KestrelServer是目前微软推出了唯一一个能够真正跨平台的Server.KestrelServer利用一个名为KestrelEngine的网络 ...

  2. ASP.NET MVC3调用PartialView的几种方式

    本文转载自: https://www.cnblogs.com/yeagen/archive/2012/09/24/2700828.html 作者:yeagen 转载请注明该声明. 我们的网页通常会有好 ...

  3. ASP.NET MVC3 快速入门

    第一节 概述    (2011-02-23 20:57:18)  转载 标签: web应用程序 分类: ASP.NETMVC3 1.1  本教程的学习内容     在本教程中,你将学会如下内容: •  ...

  4. android中11种常见传感器的使用方法

    在Android2.3 gingerbread系统中,google提供了11种传感器供应用层使用. 01#defineSENSOR_TYPE_ACCELEROMETER 1 //加速度 02#defi ...

  5. Android操作系统中11种传感器的介绍【转】

    本文转载自:http://www.oschina.net/question/163910_28354 在Android2.3 gingerbread系统中,google提供了11种传感器供应用层使用. ...

  6. Android操作系统11种传感器

    Android操作系统11种传感器介绍 在Android2.3 gingerbread系统中,google提供了11种传感器供应用层使用.      #define SENSOR_TYPE_ACCEL ...

  7. [转帖]Android操作系统11种传感器介绍

    Android操作系统11种传感器介绍 在Android2.3 gingerbread系统中,google提供了11种传感器供应用层使用. #define SENSOR_TYPE_ACCELEROME ...

  8. MTK Android操作系统11种传感器介绍

    Android操作系统11种传感器介绍 1 加速度传感器 2 磁力传感器 3 方向传感器 4 陀螺仪传感器 5 光线感应传感器 6 压力传感器 7 温度传感器 8 接近传感器 9 重力传感器 10 线 ...

  9. [译]Professional ASP.NET MVC3(01)-Chapter 1:Getting Started(上)

    本章概要 理解ASP.NET MVC ASP.NET MVC3 预览 如何创建MVC3应用程序 MVC应用程序结构 本章首先简要介绍ASP.NET MVC, 解释它怎样适应ASP.NET MVC的历史 ...

最新文章

  1. 打造全球最大规模 Kafka 集群,Uber 的多区域灾备实践
  2. µC/OS-II和µC/OS-III比较
  3. SAP Spartacus converter执行的上下文
  4. 我竟然用git send-mail通过QQ邮箱提交了push request
  5. 索引多维数组_PHP数组–索引,关联和多维
  6. emule学习与分析二 上 建立连接过程分析
  7. 【信号检测】基于matlab双稳态随机共振的参数寻优算法【含Matlab源码 1700期】
  8. JSP实用教程 第三章 JSP内置对象
  9. 轻松学习Linux之入门篇
  10. C语言—— 符号函数
  11. PC机组成——主板、芯片组与BIOS
  12. python设置单元格宽度_【部分解决】openpyxl的excel设置列宽自适应+设置行高
  13. docker安装kafka和zookeeper
  14. 伦敦银持仓分布分析技巧
  15. Java开发必知Linux命令
  16. 2015.4.28 今天开博客了
  17. [人工智能-深度学习-14]:神经网络基础 - 常见loss损失函数之逻辑分类,对数函数,交叉熵函数
  18. 四周型文字环绕怎么设置_word怎样设置四周型版式
  19. 风险预测模型评价第二弹:NRI的R语言计算
  20. MOSFET原理学习

热门文章

  1. cmd如何刷新MySQL数据库_怎样在cmd中用命令操作MySQL数据库 需要技巧
  2. keras 多层lstm_tensorflow-如何在keras中堆叠多个lstm?
  3. 160 - 28 CoSH.2
  4. 硕士毕业后去国外读法学博士_法学硕士的完整形式是什么?
  5. C++——已知a+b、 a+c、b+c、 a+b+c,求a、b、 c
  6. nutsdb与mysql_分享下 nutsdb 单机 1 亿、10 亿数据实测
  7. ipad无法充电怎么办_IPAD充电线破损无法保修,资深“果粉”吐槽:店大欺客!...
  8. c++ 中extern C 及#ifdef __cplusplus的作用
  9. 100. 相同的树 golang
  10. 【Leetcode | 顺序刷题】数学目录