Windows Azure Toolkit for Social Games(三)
来源:互联网 发布:日本对女生的审美知乎 编辑:程序博客网 时间:2024/06/06 01:33
了解过mvc大体过程后,拿到一个画面来分析下。
默认的处理是交由Home Controller的Index方法。
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
}
View的默认路径是View/Home/Index.cshtml
打开一看,代码很简单。主要是根据Request.IsAuthenticated,判断显示内容还是显示认证Link。
@{
ViewBag.Title = "Index";
}
<h2>Home</h2>
<p>
This site showcases two sample games that consumes the operations exposed by a generic game play service API. The game play service is responsible for handling the generic game operations like user authentication, joining multiple players to a game, and persisting the game live state.
</p>
@if (Request.IsAuthenticated)
{
<p>
Select an option from the menu to start playing with the samples, see your profile and friends, and check your score on the leaderboard!
</p>
}
else
{
<p>
Click @Html.ActionLink("Log On", "LogOn", "Account") to authenticate.
</p>
}
感觉代码比实际看到的内容要少。那是因为有一个~/Views/Shared/_Layout.cshtml套在外面。等同于MastePage的作用
从下图的说明可以看出只要在_ViewStart.cshtml设定一次,就不需要在每一个画面上指定_Layout.cshtml的路径了。
总体来说,这个Index画面还是很简单的,要注意的有两点:
1,ViewBag.Title = "Index";
ViewBag是View层里一个很好用的容器,你可以随时添加内容。而不需要指定类型。
2,Request.IsAuthenticated
Azure里没法用Sesion(因为每次处理的WebRoll是不同的),用户认证与否就靠Request.IsAuthenticated
Request是一个HttpRequestBase对象。
以上两点的生命周期不明,按理说Request.IsAuthenticated只能是一次Request,但它肩负着Session的作用。
- Windows Azure Toolkit for Social Games(三)
- Windows Azure Toolkit for Social Games(一)
- Windows Azure Toolkit for Social Games(二)
- 最新发布:Windows Azure Toolkit for Social Games 1.0版本
- 现在可用:Windows Azure Toolkit for Social Games Version 1.1
- 公布Windows Azure Toolkit for Windows 8
- 最新发布: Windows Azure Toolkit for Windows Phone 7 v1.2
- Windows Azure Toolkit for Windows 8 Consumer Preview的升级版发布了
- Social Games Tutorial
- Windows Azure: Cost Architecting for Windows Azure
- Windows Azure(三):结构
- Network Emulator for Windows Toolkit
- Network Emulator for Windows Toolkit
- Actor Framework for Windows Azure
- 15 Step To Hacking Windows Using Social Engineering Toolkit And Backtrack 5
- Silverlight for Windows Phone Toolkit升级说明
- NEWT (Network Emulator for Windows Toolkit)
- network emulator for windows toolkit 网络模拟器
- SQL Server字符串处理函数大全
- 工程结构范例:
- PYTHON类
- ASP.NET页的生命周期
- Hadoop in 360-专访360系统部总监唐会军
- Windows Azure Toolkit for Social Games(三)
- throws throw
- 混合高斯模型
- (SqlServer)不公开存储过程sp_Msforeachtable与sp_Msforeachdb详解
- linux 安装oracle10g 写入目录/tmp 时出错
- 【jQuery教程】jQuery基础教程笔记1
- (SqlServer)批量清理指定数据库中所有数据
- 移动设备的网络通信 http /socket
- How to install Ruby on Rails in Ubuntu 11.10