Help on session behaviour ???

G

Guest

Dear all

I have a strange behaviour using session.

ON my form load when the page is first display I create a session variable
to stor connection objects as follow :

If not IsPostBack then Then
Session.Add("DataLayer", Me.m_pCon)
else
Me.m_pCon.m_dbConnection = CType(Session("DataLayer"),
DbConParam).m_dbConnection

end if

Time to time it appears that the session object is not existing anymore,
then I retry 2 or 3 times and its again working

Any ideas why it occurs like this ?

regards
serge
 
M

mortb

The session has a timeout that is set in the web.config. I think the default
timeout is 20 minutes.
Therefore you can never rely on that the object you put into session still
exists when you recieve a post back of a page.

Hope this helps,
mortb
 
G

Guest

So that means that I should always test if object is nothing when a post back
is received and then if object is nithing reinitialise it ?
 
G

Guest

Hi Serge,

See my comments following
If not IsPostBack then Then
Session.Add("DataLayer", Me.m_pCon)

Do you init Me.m_pCon? If not it's Nothing. When postback, you retrieve
nothing from Session.

HTH

Elton Wang
 

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,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top