【发布时间】:2014-04-11 07:49:41
【问题描述】:
我想知道会话锁定机制是如何工作的,以及如何在服务器场环境中锁定变量及其各自的子对象以进行多次读取/独占写入。
场景 Web 场将使用 3 个 Windows 2003 服务器,每个服务器作为 Web 应用程序自己的应用程序域。会话对象保存在 SQL Server 2005 上。 在我的网络应用程序中使用的对象如下:
MySampleClass = class
{
public string Id;
public Dictionary<string, CustomClass1> Data;
public List<string> Commands;
public CustomClass2 MoreData;
}
其中 customClass 1 和 2 是属于应用程序一部分的业务类。
现在在其中一个网页中,代码如下所示:
Session["myObj"] = new MySampleClass();
在其他页面中:
MySampleClass = (MySampleClass)Session["myObj"];
//Is Session["myObj"] accessed in a multiple reader/exclusive writer mode? if so is it locking just the variable or the whole contents?
MySampleClass.Commands.Add("sample string");
MySampleClass.Commands.RemoveAt(0);
//More CRUD changes
//Are these changes available to other pages as soon as I finish the CRUD changes?
如果您需要更多详细信息,请告诉我
【问题讨论】:
标签: c# asp.net session-state