I have an ASP.NET application that is accessed by 120-140 users at the same time on average. I use Session to get and set user specific info. To make things easy I've got a static a class called CurrentSession and it has a property called UserInfo:
public static class CurrentSession{
public static UserInfo{
get{return HttpContext.Current.Session["userInfo"]!=null?(UserInfo)HttpContext.Current.Session["userInfo"]:null;}
set{HttpContext.Current.Session["userInfo"]=value;}
}
//And other properties
}
And whenever I needed current user's info I just used to do:
CurrentSession.UserInfo;
Recently I've come across situations when wrong user info is retrieved. Is there a problem in my approach that can cause Session conflicts?
No. It can't be that the session change can be caused by the static method. In fact, HttpContext.Current itself is a static. Assigning it to a static variable can cause this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With