SQL Server session not working...

G

Guest

I was using session mode as "InProc"(entered in web.config). I have deployed
my ASP.NET appln. on a server which uses Load Balancer. i.e I have two
servers. I am using session across pages.The problem I was facing is that
sometimes I find the session and sometimes not. I beleive this is happenning
because of multiple servers. Because session is created on a worker process
on one server and the second time it must be hitting the other server to
fetch the
session. Hence the issue.I then used SQL Server session mode but now I get
the errror "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'. "
Any Idea ? Thanks in advance..
 
W

Winista

Check all objects that you are storing in session. One of your objects is
exposing an object as public property or field which is non serialzable. An
example could be Thread object which is not serialzable.

Winista
http://www.universalshoppingmall
 
W

Winista

If there is something that does not need to be serialized, make them
non-public or decorate then with Non-serialzable attribute. You will have to
look at your objects closely to make the decision. and if there is something
that needs to be serialzable and by default does not do it by itself then
you will have to manually serialize those objects.
Also put [Serializable] attributes on your objects.
 
B

bruce barker \(sqlwork.com\)

note: some object can not be serialized, such as sqlconnections,
datareaders, streams, com interop objects, collections containing a
non-serializable object, etc. in this case you must be redesign you session
data.

you'd think, when asp.net tried to serialize session data, it would list the
name of the object. to find the offending object:

try (air code)

MemoryStream myWriter = new MemoryStream ();
foreach (string key in Session.AllKeys)
{
object o = Session[key];
try
{
XmlSerializer mySerializer = new XmlSerializer(o.GetType());
mySerializer.Serialize(myWriter, o);
}
catch
{
Debug.Print("Unable to serialize: " + key);
}
}
myWriter.Close();


-- bruce (sqlwork.com)




-- bruce (sqlwork.com)




Winista said:
If there is something that does not need to be serialized, make them
non-public or decorate then with Non-serialzable attribute. You will have
to look at your objects closely to make the decision. and if there is
something that needs to be serialzable and by default does not do it by
itself then you will have to manually serialize those objects.
Also put [Serializable] attributes on your objects.

NAT said:
So do I need to serialize it ? How can i ?
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top