苏飞论坛

标题: HttpContext.Current.User.Identity.Name [打印本页]

作者: 羽毛    时间: 2013-5-22 10:11
标题: HttpContext.Current.User.Identity.Name
今天看程序源码发现一些代码无法理解
  1.         public UserCache()
  2.         {
  3.             this.currentUser = HttpContext.Current.User.Identity.Name;
  4.             if (HttpContext.Current.Cache["AnyOffice_User_" + this.currentUser] == null)
  5.             {
  6.                 this.UpdateUserName();
  7.             }
  8.         }
  9.         public UserCache(string userId)
  10.         {
  11.             this.currentUser = userId;
  12.             if (HttpContext.Current.Cache["AnyOffice_User_" + this.currentUser] == null)
  13.             {
  14.                 this.UpdateUserName();
  15.             }
  16.         }
复制代码
第二个方法可以理解,将值存在HttpContext.Current.Cache 中用唯一的 KEY值去获取到信息,
可第一个方法怎么说,HttpContext.Current.User.Identity.Name 获取当前用户的名称,这不是在表示层,怎么能获取到当前用户的信息呢?




欢迎光临 苏飞论坛 (http://www.sufeinet.com/) Powered by Discuz! X3.4