这个问题的背景是我需要在(静态)WebMethod 中使用一些用户会话数据。我创建了一个引用我需要的数据的静态属性,如下所示:
private static UserWebSession UserWebSession
{
get
{
return (UserWebSession)HttpContext.Current.Session["UserWebSession"];
}
}
然后我可以在我的页面的静态 WebMethod 中调用它。
我的问题是,这种技术线程安全吗?或者这个属性的值是否会随着每个新的页面请求而更新 - 换句话说,它将返回最近请求页面的用户的 UserWebSession?