Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Objects stored in session using Sql Server

Reply
Thread Tools

Objects stored in session using Sql Server

 
 
wdudek
Guest
Posts: n/a
 
      02-26-2008
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.

 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      02-26-2008
wdudek wrote:
> 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.


There was no way for you to know it (except maybe by browsing through
some of the previous questions before posting yours - always a
recommended practice), but this is a classic asp newsgroup. ASP.Net is
a different technology from classic ASP. While you may be lucky enough
to find a dotnet-savvy person here who can answer your question, you
can eliminate the luck factor by posting your question to a newsgroup
where the dotnet-savvy people hang out. I suggest
microsoft.public.dotnet.framework.aspnet.
There are also forums at www.asp.net where you can find a lot of people
to help you.


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
 
 
 
Steven Cheng
Guest
Posts: n/a
 
      02-27-2008
Hi Bill,

As for the "document" you mentioned for ASP.NET session state, I think the
IT guys on your side pick up them from the MSDN document of ASP.NET session
state settings. Yes, for SQL server session mode, it require all the
objects(that'll be stored in it) to be serializable. However, I still not
sure whether this is the exact cause of your problem since serializable
class objects should be stored in session state correctly. Would you post
some info of the class(that cause the problem) or a simplified class that
can demonstrate this same problem. If you haven't tested some other class
or simple types, I suggest you try performing the same test with some other
built-in simple types or custom types(be serializable) to see whether the
same problem will occur.

Also, as Bob suggest, you should post such kind of ASP.NET issues in the
ASP.NET newsgroups such as microsoft.public.dotnet.framework.aspnet

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: =?Utf-8?B?d2R1ZGVr?= <(E-Mail Removed)>
>Subject: Objects stored in session using Sql Server
>Date: Tue, 26 Feb 2008 11:32:02 -0800


>
>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.
>
>


 
Reply With Quote
 
wdudek
Guest
Posts: n/a
 
      02-27-2008
Thanks,

I didn't realize this wasn't and asp.net group. I'll give your advice a
try and also repost in the suggested group.

""Steven Cheng"" wrote:

> Hi Bill,
>
> As for the "document" you mentioned for ASP.NET session state, I think the
> IT guys on your side pick up them from the MSDN document of ASP.NET session
> state settings. Yes, for SQL server session mode, it require all the
> objects(that'll be stored in it) to be serializable. However, I still not
> sure whether this is the exact cause of your problem since serializable
> class objects should be stored in session state correctly. Would you post
> some info of the class(that cause the problem) or a simplified class that
> can demonstrate this same problem. If you haven't tested some other class
> or simple types, I suggest you try performing the same test with some other
> built-in simple types or custom types(be serializable) to see whether the
> same problem will occur.
>
> Also, as Bob suggest, you should post such kind of ASP.NET issues in the
> ASP.NET newsgroups such as microsoft.public.dotnet.framework.aspnet
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
>
> ==================================================
>
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscripti...ult.aspx#notif
> ications.
>
>
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscripti...t/default.aspx.
>
> ==================================================
>
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> --------------------
> >From: =?Utf-8?B?d2R1ZGVr?= <(E-Mail Removed)>
> >Subject: Objects stored in session using Sql Server
> >Date: Tue, 26 Feb 2008 11:32:02 -0800

>
> >
> >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.
> >
> >

>
>

 
Reply With Quote
 
Steven Cheng
Guest
Posts: n/a
 
      02-28-2008
Thanks for your reply Bill,

Please feel free to followup in the new thead.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>Thread-Topic: Objects stored in session using Sql Server
>thread-index: Ach5d7Prt67tj9RsQyeNLimLOjEeMQ==
>X-WBNR-Posting-Host: 199.106.94.142
>From: =?Utf-8?B?d2R1ZGVr?= <(E-Mail Removed)>
>References: <(E-Mail Removed)>

<(E-Mail Removed)>
>Subject: RE: Objects stored in session using Sql Server
>Date: Wed, 27 Feb 2008 11:34:00 -0800


>
>Thanks,
>
> I didn't realize this wasn't and asp.net group. I'll give your advice

a
>try and also repost in the suggested group.
>
>""Steven Cheng"" wrote:
>
>> Hi Bill,
>>
>> As for the "document" you mentioned for ASP.NET session state, I think

the
>> IT guys on your side pick up them from the MSDN document of ASP.NET

session
>> state settings. Yes, for SQL server session mode, it require all the
>> objects(that'll be stored in it) to be serializable. However, I still

not
>> sure whether this is the exact cause of your problem since serializable
>> class objects should be stored in session state correctly. Would you

post
>> some info of the class(that cause the problem) or a simplified class

that
>> can demonstrate this same problem. If you haven't tested some other

class
>> or simple types, I suggest you try performing the same test with some

other
>> built-in simple types or custom types(be serializable) to see whether

the
>> same problem will occur.
>>
>> Also, as Bob suggest, you should post such kind of ASP.NET issues in the
>> ASP.NET newsgroups such as microsoft.public.dotnet.framework.aspnet
>>
>> Sincerely,
>>
>> Steven Cheng
>>
>> Microsoft MSDN Online Support Lead
>>
>> >>

>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
when to use state server out procees session and sql server out process session sunkrajesh ASP .Net 0 05-31-2009 12:03 PM
Reading the session information that is stored in SQL server. Mufasa ASP .Net 1 11-08-2007 07:33 PM
Application and Session state stored in SQL Server Michael ASP .Net 2 11-26-2005 04:15 AM
Unable to serialize the session state. Please note that non-serializable objects or MarshalByRef objects are not permitted when session state mode is 'StateServer' or 'SQLServer'. Mike Larkin ASP .Net 1 05-23-2005 12:33 PM
sql server session state stored proc recompilation Jason Collins ASP .Net 5 08-28-2003 02:19 PM



Advertisments