A
Aleksey Dmitriyev
I am using Session property for my own serializable objects. The code
snippet is below:
// C# ASP.NET code behind
private void btnRun_Click(object sender, System.EventArgs e)
{
MyClass myObj = new MyClass("abc", 99);
Session["key1"] = myObj;
myObj.SetValues("xyz", 123 );
myObj.m_inner = new MyClassInner("my inner obj", 555);
}
private void btnGetState_Click(object sender, System.EventArgs e)
{
MyClass myObj = (MyClass)Session["key1"];
if (myObj != null) lblData.Text = myObj.ToString();
}
It works fine in all three modes "InProc", "StateServer", "SQLServer". I
don't see any problems with modifying object after it was put in the
session. However someone mentioned that it might cause some problems. Can
anyone think of any problems with that?
Another question about how MS implements their session state management. It
looks like they keep references to all object in an internal in-proc
dictionary until the end of request and then they persist the whole
dictionary? Does anyone know details? On what event it the dictionary is
serialized?
Thanks,
A.D.
snippet is below:
// C# ASP.NET code behind
private void btnRun_Click(object sender, System.EventArgs e)
{
MyClass myObj = new MyClass("abc", 99);
Session["key1"] = myObj;
myObj.SetValues("xyz", 123 );
myObj.m_inner = new MyClassInner("my inner obj", 555);
}
private void btnGetState_Click(object sender, System.EventArgs e)
{
MyClass myObj = (MyClass)Session["key1"];
if (myObj != null) lblData.Text = myObj.ToString();
}
It works fine in all three modes "InProc", "StateServer", "SQLServer". I
don't see any problems with modifying object after it was put in the
session. However someone mentioned that it might cause some problems. Can
anyone think of any problems with that?
Another question about how MS implements their session state management. It
looks like they keep references to all object in an internal in-proc
dictionary until the end of request and then they persist the whole
dictionary? Does anyone know details? On what event it the dictionary is
serialized?
Thanks,
A.D.