Help on session behaviour ???

Discussion in 'ASP .Net' started by =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=, Jan 20, 2006.

  1. 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
    =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=, Jan 20, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=

    mortb Guest

    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


    "serge calderara" <> wrote in
    message news:...
    > 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
    mortb, Jan 20, 2006
    #2
    1. Advertising

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


    "mortb" wrote:

    > 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
    >
    >
    > "serge calderara" <> wrote in
    > message news:...
    > > 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

    >
    >
    >
    =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=, Jan 20, 2006
    #3
  4. 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
    =?Utf-8?B?RWx0b24gVw==?=, Jan 20, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Smythe
    Replies:
    3
    Views:
    1,225
    Jeff Smythe
    Jan 2, 2004
  2. =?Utf-8?B?Um9iSEs=?=
    Replies:
    4
    Views:
    5,250
    =?Utf-8?B?Um9iSEs=?=
    Apr 11, 2007
  3. Nikko
    Replies:
    1
    Views:
    484
    Harry
    Apr 30, 2007
  4. Andy Chambers
    Replies:
    1
    Views:
    374
    Daniel Dyer
    May 14, 2007
  5. Jazzis
    Replies:
    2
    Views:
    232
    Jazzis
    Sep 23, 2003
Loading...

Share This Page