在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();

}

}

ASP.NET MVC3默认提供了11种ActionResult的实现的更多相关文章

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

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

  2. 经典ASP.NET MVC3.0入门详解

    http://blog.csdn.net/csh624366188/article/details/7064269 :由于本文原在word文档里编写,写本文章时运用了大量截图,直接复制到博客里,没有显 ...

  3. ASP.NET MVC3 系列教程 - Razor视图引擎基础语法

    http://www.cnblogs.com/highend/archive/2011/04/09/aspnet_mvc3_razor_engine.html 4. 关于所有带"_" ...

  4. ASP.NET MVC3快速入门——第五节、从控制器访问模型中的数据

    5.1 从控制器访问模型中的数据在本节中,我们将创建一个新的MoviesController类,并且书写代码来获取数据库中的数据,并通过视图模板来显示在浏览器中.鼠标右击Controller文件夹,点 ...

  5. 实现Android操作系统11种传感器介绍

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

  6. ASP.NET MVC3 入门指南之数据验证[源码RAR下载]

    http://www.cnblogs.com/BingoLee/archive/2011/12/23/2298822.html 前言: 无论你编写什么样的网页程序,都需要对用户的数据进行验证,以确数据 ...

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

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

  8. Java默认提供的线程池

    Java的线程池都是通过ThreadPoolExecutor来构建. public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, ...

  9. .NET开发人员必看:提高ASP.NET Web应用性能的24种方法和技巧

    那性能问题到底该如何解决?以下是应用系统发布前,作为 .NET 开发人员需要检查的点. 1.debug=「false」 当创建 ASP.NET Web应用程序,默认设置为「true」.开发过程中,设置 ...

随机推荐

  1. uva10417 概率DP

    这题 to[i][j] 为第i个人送j这个礼物的概率 我们用13进制进行压缩这个留下的的礼物的个数,这样我们将dp[i][k]表示为当第i个人放完礼物后得到的状态为k时的概率,那么通过记忆化搜索我们就 ...

  2. ng-深度学习-课程笔记-8: 超参数调试,Batch正则(Week3)

    1 调试处理( tuning process ) 如下图所示,ng认为学习速率α是需要调试的最重要的超参数. 其次重要的是momentum算法的β参数(一般设为0.9),隐藏单元数和mini-batc ...

  3. GPS数据解析

    1.摘要 GPS模块使用串口通信,那么它的的数据处理本质上还是串口通信处理,只是GPS模块的输出的有其特定的格式,需要字符串处理逻辑来解析其含义.如何高效的处理从GPS模块接收到的数据帧,是GPS驱动 ...

  4. INNODB索引与算法

    在之前的博文中简单提到了索引的分类与索引的可选择性查看:Click HERE 这片博客主要包含内容:索引组织表,索引算法B+树简单介绍 索引组织表 在innodb存储引擎中,表都是根据主键顺序组织存放 ...

  5. hdu3037 Saving Beans(Lucas定理)

    hdu3037 Saving Beans 题意:n个不同的盒子,每个盒子里放一些球(可不放),总球数<=m,求方案数. $1<=n,m<=1e9,1<p<1e5,p∈pr ...

  6. img = img1*mask + img2*(1-mask) How do that ?

    原文地址:http://answers.opencv.org/question/160599/img-img1mask-img21-mask-how-do-that/ 如何提高一个简单操作的速度?最后 ...

  7. 20145201李子璇 《网络对抗》 Web安全基础实践

    1.实验后回答问题 (1)SQL注入攻击原理,如何防御 原理:通过构建特殊的输入作为参数传入web应用程序.即把SQL命令注入到Web表单的输入域或页面请求的查询字符串,和之前已经设定好的查询语句构成 ...

  8. [3dSmartSystem] - Java&3d

    Java如果简单的做为Dynamic web project的工具来说,实现数据的前端到后端的传递及存储等. 就像一个银行,你去柜台(前端)给服务人员或者机器一些钱,之后输入密码,然后服务人员(后端处 ...

  9. 51Nod 1737 配对(树的重心)

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1737 题意: 思路: 树的重心. 树的重心就是其所以子树的最大的子树结点 ...

  10. c++ 计算指定半径圆的面积

    #include <iostream> #define PI 3.14 using namespace std; class Circle { float radius; public: ...