Objects stored in session using Sql Server

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

Bob Barrows [MVP]

wdudek said:
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.
 
S

Steven Cheng

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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.

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


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

--------------------
 
W

wdudek

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

Steven Cheng

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?= <[email protected]>
References: <[email protected]>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,708
Messages
2,569,347
Members
44,654
Latest member
7Jhamal74

Latest Threads

Top