这个问题在这里解释了这个问题 Is it safe to access asp.net session variables through static properties of a static object? 但我的例子可能更复杂,是否安全?
public static class SessionManager
{
public static tbuser User
{
get
{
var user = HttpContext.Current.Session["User"] as tbuser
user.money = RetriveFromDb(user.name)
HttpContext.Current.Session["User"] = user;
return user;
}
set { HttpContext.Current.Session["User"] = value; }
}
}