RE: Session management on web farm with sql server
- From: stcheng@xxxxxxxxxxxxxxxxxxxx ("Steven Cheng")
- Date: Fri, 29 Feb 2008 05:15:54 GMT
Hi Bill,
For binary serialization and implement your custom serialization approach,
here are some reference that should be helpful:
#Run-time Serialization
http://msdn.microsoft.com/msdnmag/issues/02/04/net/
#Serialization in the .NET Framework
http://www.15seconds.com/issue/020903.htm
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: =?Utf-8?B?d2R1ZGVr?= <wdudek@xxxxxxxxxxxxxxxx><1D85C258-6104-4E4A-9F18-050635B2909D@xxxxxxxxxxxxx>
References: <9E5A2E55-EA73-475D-A7E0-29C503F212D8@xxxxxxxxxxxxx>
Subject: RE: Session management on web farm with sql server
Date: Thu, 28 Feb 2008 10:57:02 -0800
understand
Thanks,
This explains exactly what is happening. I can look this up, but is
anyone aware of any links that discuss this issue in more depth? I
the concept of custom serialization but have never worked with it.static
Thanks again
Bill
"bruce barker" wrote:
session is a collection of objects. with in proc, this collection is a
sessioncollection. with out-of-proc session managers (like sqlsession), the
thecollection is an instance collection tired to the request. at the end of
itsrequest, it serialized out to the store. at the start of the request,
differencedeserialied from the store. during request processing, there is no
serializing/deserializingbetween inproc and out-of-proc sessions.
if you see a difference. then you object is not
deserialized.correctly. you will have to fix the logic. the most common issue, is not
handling mulitple to references to the same object correctly.
simple example:
// first request
myObject obj = new myObject();
List<myObject> list = new List<myObject>();
list.Add(obj);
list.Add(obj);
Session["list"] = list;
list[0].Value="1"; // list[0].Value == list[1].Value == "1";
list[0].Value="2"; // list[0].Value == list[1].Value == "2";
// next request
List<myObject> list = (myObject) Session["list'];
list[0]="3"; // list[0].Value != list[1].Value
this is because at serialzztion time list[0] & list[1] where
value.when deserialiezed, two objects were created, but each with the same
serializenow changing one does not change the other.
so, if your object has mutiple refences to the same object (say the same
object is in two collections) then you have to write a custom serializer.
the approach i use for complex objects I store in session, is there is a
base collection that objects belong to, and other references just
howeverthe lookup key.
-- bruce (sqlwork.com)
"wdudek" wrote:
We have a website that works fine when hosted on a single server,
Serverit experiences some strange problems when run on a web farm using SQL
call anto handle session state. When running on the farm, in the same method
session,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
tries toaltered and placed back in session before a following line of code
severaluse
the altered value, only to find out that it appears to have never been
changed. The application essentially stores 1 object that contains
thatother
objects in session. The group that manages teh web farm is telling me
innerthis is the problem. They are saying that because of the
serialization/deserialization in sql server, the reference to the
Server. Doesobjects isn't flowing through to the object being stored in SQL
website codethis sound correct? Should there be any differance between how a
thefuncitons on a single server versus a web farm? They provided me with
camebelow documentation, but have not yet been able to tell me where it
anyfrom. This has been an ongoing battle over who's problem it really is,
theinformation on this subject will be appreciated. Also as a note all of
sessionobjects are serializable.
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
issue isobjects get created, retrieved and updated in the SQL Server. The
inwith 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
dataAppDomain 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
deserializefrom database and deserialize it and creates the objects with
referencesdata and bind them to state bag. In this mode the actual object
sessionand session object references are different.
Because of this, the S&S application is able to retrieve data when
application isis in InProc but not in SQL Server. What's happening in S&S
ownas
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
correctly.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
.
- Follow-Ups:
- RE: Session management on web farm with sql server
- From: wdudek
- RE: Session management on web farm with sql server
- References:
- Session management on web farm with sql server
- From: wdudek
- RE: Session management on web farm with sql server
- From: bruce barker
- RE: Session management on web farm with sql server
- From: wdudek
- Session management on web farm with sql server
- Prev by Date: Re: error with ajax 1 and updatepanel
- Next by Date: Re: ASP/ASP.NET page that reacts a special way to items coming from a particular subdomain (programmatically testing subdomain?)
- Previous by thread: RE: Session management on web farm with sql server
- Next by thread: RE: Session management on web farm with sql server
- Index(es):
Relevant Pages
|