请教高手关于缓存用户信息后信息混乱的情况。
请教一个问题。在asp.net中我写了一个基类,在基类里面缓存了登陆人的信息,所有页面继承这个基类。结果当第一个人登陆后,第二个人登陆了就显示了第一个人的信息。请问这个怎么解决。
我基类的方法如下:
PerModel.usr_userView model = Cache["BasePage_userModel"] as PerModel.usr_userView;//从缓存中读取数据 if (model == null) { string[] tableName = new string[] { "Usr_User", "Per_Dictionary", "Architecture" }; AggregateCacheDependency aggregateDependency = new AggregateCacheDependency();//实例化AggregateCacheDependency,用于多个实例SqlCacheDependency的加载 model = userBll.GetUserInfo(Session["UserId"].ToString()); foreach (string table in tableName) { aggregateDependency.Add(new SqlCacheDependency("NewOA", table));//把依赖实例加载到数组中 } if (model != null) { Cache.Insert("BasePage_userModel", model, aggregateDependency);//添加到缓存中 } } if (model != null) { UserID = model.ID; UserLoginName = model.UserId; UserRealName = model.UserName; DepartmentID = model.Org; DepartmentName = model.OrgName; } }