Asp.net: how a session works in a server farm environment

I would like to know how the session locking mechanism works and how I can lock a variable and its children for multiple read / write exceptions in a server farm environment.

The Web Farm scenario will use 3 Windows 2003 servers, each of which is its own application domain for the web application. The sesion object is saved on SQL Server 2005. The object that will be used in my web application is as follows:

MySampleClass = class
{
  public string Id;
  public Dictionary<string, CustomClass1> Data;
  public List<string> Commands;
  public CustomClass2 MoreData;
}

where customClass 1 and 2 are business classes that are part of the application.

Now on one of the web pages the code will look like this:

Session["myObj"] = new MySampleClass();

on other pages:

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?

let me know if you need more information

+3
2

" ". , , , , 1/2, .

+3

" " msdn.

, ASP.NET.

0

Source: https://habr.com/ru/post/1719466/


All Articles