Global.asax and Session State

Discussion in 'ASP .Net' started by stewartfip@yahoo.com, Sep 27, 2005.

  1. Guest

    My global.asax file looks something like this:

    sub Session_Start()
    [some database activity]

    session("sessionID") = [value from cmd output param]
    end sub

    sub Application_PreRequestHandlerExecute()
    if session("sessionID") <> 0 then
    [do some stuff]
    end if
    end sub

    ....which seems to have worked fine up until this weekend. I have a
    simple routine that e-mails application errors to me and I've been
    HAMMERED suddenly with 'Session state is not available in this context'
    on the line that reads 'if session("sessionID") <> 0 then...' which
    doesn't make sense because Application_PreRequestHandlerExecute was
    supposed to be a safe place to mess around with session variables.

    So I'm at a loss in terms of where to begin troubleshooting this
    problem. Am I referencing session variables in too simple a manner?
    At this point, I'm not clear if this is happening to a given user on
    every page, or if it just happens on their first page view and then
    things are fine thereafter. I get an error every, oh, three minutes.
    So it's happening a lot.

    I'll provide more details, just tell me what you need to know. I'm
    reasonably new to ASP.Net and am using VB, if that wasn't completely
    obvious.
     
    , Sep 27, 2005
    #1
    1. Advertising

  2. I experienced the same issue after updating the IIS properies for my site
    from ASP 1.1 to ASP 2.0. I switched it back to 1.1 until I recode around the
    issue, and the problem did go away.

    I would also like to know why Session is no longer valid at this point in
    Global.asax.

    "" wrote:

    > My global.asax file looks something like this:
    >
    > sub Session_Start()
    > [some database activity]
    >
    > session("sessionID") = [value from cmd output param]
    > end sub
    >
    > sub Application_PreRequestHandlerExecute()
    > if session("sessionID") <> 0 then
    > [do some stuff]
    > end if
    > end sub
    >
    > ....which seems to have worked fine up until this weekend. I have a
    > simple routine that e-mails application errors to me and I've been
    > HAMMERED suddenly with 'Session state is not available in this context'
    > on the line that reads 'if session("sessionID") <> 0 then...' which
    > doesn't make sense because Application_PreRequestHandlerExecute was
    > supposed to be a safe place to mess around with session variables.
    >
    > So I'm at a loss in terms of where to begin troubleshooting this
    > problem. Am I referencing session variables in too simple a manner?
    > At this point, I'm not clear if this is happening to a given user on
    > every page, or if it just happens on their first page view and then
    > things are fine thereafter. I get an error every, oh, three minutes.
    > So it's happening a lot.
    >
    > I'll provide more details, just tell me what you need to know. I'm
    > reasonably new to ASP.Net and am using VB, if that wasn't completely
    > obvious.
    >
    >
     
    =?Utf-8?B?SmhvbmRh?=, Dec 9, 2005
    #2
    1. Advertising

  3. Afaik everything in Application_ is not related to session.
    Unf. i needed as well :)



    "Jhonda" <> schreef in bericht
    news:...
    >I experienced the same issue after updating the IIS properies for my site
    > from ASP 1.1 to ASP 2.0. I switched it back to 1.1 until I recode around
    > the
    > issue, and the problem did go away.
    >
    > I would also like to know why Session is no longer valid at this point in
    > Global.asax.
    >
    > "" wrote:
    >
    >> My global.asax file looks something like this:
    >>
    >> sub Session_Start()
    >> [some database activity]
    >>
    >> session("sessionID") = [value from cmd output param]
    >> end sub
    >>
    >> sub Application_PreRequestHandlerExecute()
    >> if session("sessionID") <> 0 then
    >> [do some stuff]
    >> end if
    >> end sub
    >>
    >> ....which seems to have worked fine up until this weekend. I have a
    >> simple routine that e-mails application errors to me and I've been
    >> HAMMERED suddenly with 'Session state is not available in this context'
    >> on the line that reads 'if session("sessionID") <> 0 then...' which
    >> doesn't make sense because Application_PreRequestHandlerExecute was
    >> supposed to be a safe place to mess around with session variables.
    >>
    >> So I'm at a loss in terms of where to begin troubleshooting this
    >> problem. Am I referencing session variables in too simple a manner?
    >> At this point, I'm not clear if this is happening to a given user on
    >> every page, or if it just happens on their first page view and then
    >> things are fine thereafter. I get an error every, oh, three minutes.
    >> So it's happening a lot.
    >>
    >> I'll provide more details, just tell me what you need to know. I'm
    >> reasonably new to ASP.Net and am using VB, if that wasn't completely
    >> obvious.
    >>
    >>
     
    Edwin Knoppert, Dec 9, 2005
    #3
    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. Earl Teigrob

    Global Session Variables and Session State

    Earl Teigrob, Dec 16, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    4,278
    Alvin Bruney
    Dec 17, 2003
  2. =?Utf-8?B?YmNoYXJsZXM=?=

    global.asax and global.asax.cs

    =?Utf-8?B?YmNoYXJsZXM=?=, Oct 4, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    842
    =?Utf-8?B?YmNoYXJsZXM=?=
    Oct 5, 2004
  3. Mark Rae

    Global.asax / Global.asax.cs in v2

    Mark Rae, May 23, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    3,168
    Mark Rae
    May 23, 2006
  4. jnickfl1
    Replies:
    0
    Views:
    595
    jnickfl1
    Sep 18, 2006
  5. archana
    Replies:
    0
    Views:
    348
    archana
    Mar 13, 2007
Loading...

Share This Page