|
|
今天看程序源码发现一些代码无法理解- public UserCache()
- {
- this.currentUser = HttpContext.Current.User.Identity.Name;
- if (HttpContext.Current.Cache["AnyOffice_User_" + this.currentUser] == null)
- {
- this.UpdateUserName();
- }
- }
- public UserCache(string userId)
- {
- this.currentUser = userId;
- if (HttpContext.Current.Cache["AnyOffice_User_" + this.currentUser] == null)
- {
- this.UpdateUserName();
- }
- }
复制代码 第二个方法可以理解,将值存在HttpContext.Current.Cache 中用唯一的 KEY值去获取到信息,
可第一个方法怎么说,HttpContext.Current.User.Identity.Name 获取当前用户的名称,这不是在表示层,怎么能获取到当前用户的信息呢? |
|