views:

153

answers:

1

I would like to know in how the Session locking mechanism work and how I can lock a variable and its respective child objects for multiple reads/exclusive write in a server farm environment.

Scenario The web farm will use 3 Windows 2003 servers, each server as its own app domain for the Web application. The sesion object is saved on SQL Server 2005. The object to use in my web app is at follows: MySampleClass = class { public string Id; public Dictionary Data; public List Commands; public CustomClass2 MoreData; }

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

now in one of the web pages, code will look like:

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

in 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 details

+1  A: 

Have a look here under Locking Session-Store Data. Basically, unless your page says it wants read-only session access, the session is locked on the DB and other callers for that session will poll at 1/2sec interval until it is unlocked.

nitzmahone
Thanks, just need to add that session is dictionary based.
mas_oz2k1