W
wdudek
We have a website that works fine when hosted on a single server, however it
experiences some strange problems when run on a web farm using SQL Server to
handle session state. When running on the farm, in the same method call an
object that just had a value set will no longer have the value set a couple
of lines later. In this example the object is pulled out of session, altered
and placed back in session before a following line of code tries to use the
altered value, only to find out that it appears to have never been changed.
The application essentially stores 1 object that contains several other
objects in session. The group that manages teh web farm is telling me that
this is the problem. They are saying that because of the
serialization/deserialization in sql server, the reference to the inner
objects isn't flowing through to the object being stored in SQL Server. Does
this sound correct? Should there be any differance between how a website code
funcitons on a single server versus a web farm? They provided me with the
below documentation, but have not yet been able to tell me where it came
from. This has been an ongoing battle over who's problem it really is, any
information on this subject will be appreciated.
Thanks,
Bill
This is the reponse I got from our techincal support group
There is no problem with the SQL Server settings for storing the session as
session objects get created, retrieved and updated in the SQL Server. The
issue is with the way the session object is updated in the C# code.
Session in asp.net behaves as follows.
InProc: In this mode session data is stored in the AppDomain of the
application. All the objects stored in the session are actually stored in
AppDomain and a reference is created for the session.
SQL Server/State Server: In this mode session data is serialized and stored
in SQL server database. When sessions is loaded system will fetch the data
from database and deserialize it and creates the objects with deserialize
data and bind them to state bag. In this mode the actual object references
and session object references are different.
Because of this, the S&S application is able to retrieve data when session
is in InProc but not in SQL Server. What's happening in S&S application is as
below.
In case of InProc session Inquiry object and Search object have
same reference, so updating one object is will show effect all its references.
In case of SQL Server session each object will have its own
reference (each time new object is created from deserialize data), so
updating one object will not update the other object in the session.
To solve this, C# code needs to be modified where the session related
objects are updated such that it gets updated in the session correctly.
experiences some strange problems when run on a web farm using SQL Server to
handle session state. When running on the farm, in the same method call an
object that just had a value set will no longer have the value set a couple
of lines later. In this example the object is pulled out of session, altered
and placed back in session before a following line of code tries to use the
altered value, only to find out that it appears to have never been changed.
The application essentially stores 1 object that contains several other
objects in session. The group that manages teh web farm is telling me that
this is the problem. They are saying that because of the
serialization/deserialization in sql server, the reference to the inner
objects isn't flowing through to the object being stored in SQL Server. Does
this sound correct? Should there be any differance between how a website code
funcitons on a single server versus a web farm? They provided me with the
below documentation, but have not yet been able to tell me where it came
from. This has been an ongoing battle over who's problem it really is, any
information on this subject will be appreciated.
Thanks,
Bill
This is the reponse I got from our techincal support group
There is no problem with the SQL Server settings for storing the session as
session objects get created, retrieved and updated in the SQL Server. The
issue is with the way the session object is updated in the C# code.
Session in asp.net behaves as follows.
InProc: In this mode session data is stored in the AppDomain of the
application. All the objects stored in the session are actually stored in
AppDomain and a reference is created for the session.
SQL Server/State Server: In this mode session data is serialized and stored
in SQL server database. When sessions is loaded system will fetch the data
from database and deserialize it and creates the objects with deserialize
data and bind them to state bag. In this mode the actual object references
and session object references are different.
Because of this, the S&S application is able to retrieve data when session
is in InProc but not in SQL Server. What's happening in S&S application is as
below.
In case of InProc session Inquiry object and Search object have
same reference, so updating one object is will show effect all its references.
In case of SQL Server session each object will have its own
reference (each time new object is created from deserialize data), so
updating one object will not update the other object in the session.
To solve this, C# code needs to be modified where the session related
objects are updated such that it gets updated in the session correctly.