C# Asp.net:会话在服务器场环境中的工作方式

C# Asp.net:会话在服务器场环境中的工作方式,c#,asp.net,session-state,C#,Asp.net,Session State,我想了解会话锁定机制是如何工作的,以及如何在服务器场环境中锁定变量及其各自的子对象以进行多次读取/独占写入 情景 web场将使用3台Windows 2003服务器,每台服务器都作为web应用程序的自己的应用程序域。sesion对象保存在SQL Server 2005上。 “我的web应用”中要使用的对象位于以下位置: MySampleClass = class { public string Id; public Dictionary<string, CustomClass1>

我想了解会话锁定机制是如何工作的,以及如何在服务器场环境中锁定变量及其各自的子对象以进行多次读取/独占写入

情景 web场将使用3台Windows 2003服务器,每台服务器都作为web应用程序的自己的应用程序域。sesion对象保存在SQL Server 2005上。 “我的web应用”中要使用的对象位于以下位置:

MySampleClass = class
{
  public string Id;
  public Dictionary<string, CustomClass1> Data;
  public List<string> Commands;
  public CustomClass2 MoreData;
}
在其他页面中:

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?

如果需要更多详细信息,请与我联系

查看锁定会话存储数据下的内容。基本上,除非您的页面说它需要只读会话访问,否则会话将锁定在DB上,该会话的其他调用者将以1/2秒的间隔进行轮询,直到它被解锁。

还有一个详细的解释


它介绍了在ASP.NET中使用进程外会话状态提供程序时使用的算法和规则。

谢谢,只需添加基于字典的会话即可。
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?