标签:username null 登陆 size car font rect drop data-
有兴趣的可以看看菜鸟教程的 http://www.runoob.com/aspnet/razor-cs-loops.html
1.ViewData展示登陆的Session信息
Controller:
1 public ActionResult Index() 2 { 3 if (Session["username"] == null) 4 { 5 Response.Redirect("/Login/Index"); 6 } 7 else 8 { 9 ViewData["username"] = Session["username"].ToString(); 10 } 11 return View(); 12 }
View:
1 <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" 2 aria-expanded="false"> 3 <i class="fa fa-user-o fa-fw"></i> 4 @if (ViewData["username"]!=null) 5 { 6 @ViewData["username"].ToString(); 7 } 8 <span class="caret"></span> 9 </a>
效果:
标签:username null 登陆 size car font rect drop data-
原文地址:http://www.cnblogs.com/XYBF-Mars/p/6259364.html