Problem with Session_End in Global.asax

Discussion in 'ASP .Net' started by =?Utf-8?B?QmVsYQ==?=, Apr 13, 2004.

  1. Hello

    I was wondering if someone could help me out with a Session_End problem in my Global.asax. I've tried everything, and still no success
    Here is the scenario: sessionstate is set to InProc. I have timeout set to 1 min
    I have a variable in session_start that is incremented each new session, and it is then decremented in Session_End. I use this variable on a web form to show current users online. All of this works just fine, so I know that session_end event handler is firing
    I also have the following in the Application_AuthenticateRequest handler:(This is an instance method that performs an update stored procedure in Sql Server 2000, and it also works fine
    Activity myActivity = new Activity( )
    myActivity.Method(User.Identity.Name.ToString( ), true)

    Here's the prob: Session_end also contains this
    Activity myActivity = new Activity( )
    myActivity.Method(User.Identity.Name.ToString( ), false)

    when the session timeout occurs after 1 min, this procedure does not work. What am I doing wrong? Please help. The decrementing of the variable works in session_end, why won't this
    Thank you in advance for any help on this subject.
    =?Utf-8?B?QmVsYQ==?=, Apr 13, 2004
    #1
    1. Advertising

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

    Cliff Harris Guest

    I created a quick test app to see if I could repro your problem, and I did.
    I think I figured out why it is failing as well.
    When I went debugging through the code and set a breakpoint in the
    Session_End event and tried to access User.Identity, an exception was
    thrown. You don't see this exception because it is apparently squished and
    ignored by ASP.Net.

    From what I can gather, in the Session_End event the login information has
    already been lost and therefore User.Identidy fails. I am going to assume
    that the counter that you decrement is before the code that accesses
    User.Identity. That code will get executed which is why the counter is
    working, but because User.Identity fails, your call to
    myActivity.Method(...) fails.

    HTH,
    -Cliff

    "Bela" <> wrote in message
    news:...
    > Hello,
    >
    > I was wondering if someone could help me out with a Session_End problem in

    my Global.asax. I've tried everything, and still no success!
    > Here is the scenario: sessionstate is set to InProc. I have timeout set

    to 1 min.
    > I have a variable in session_start that is incremented each new session,

    and it is then decremented in Session_End. I use this variable on a web
    form to show current users online. All of this works just fine, so I know
    that session_end event handler is firing.
    > I also have the following in the Application_AuthenticateRequest

    handler:(This is an instance method that performs an update stored procedure
    in Sql Server 2000, and it also works fine)
    > Activity myActivity = new Activity( );
    > myActivity.Method(User.Identity.Name.ToString( ), true);
    >
    > Here's the prob: Session_end also contains this:
    > Activity myActivity = new Activity( );
    > myActivity.Method(User.Identity.Name.ToString( ), false);
    >
    > when the session timeout occurs after 1 min, this procedure does not work.

    What am I doing wrong? Please help. The decrementing of the variable works
    in session_end, why won't this?
    > Thank you in advance for any help on this subject.
    Cliff Harris, Apr 13, 2004
    #2
    1. Advertising

  3. =?Utf-8?B?QmVsYQ==?=

    coollzh Guest

    i think you should debug you function
    myActivity.Method(User.Identity.Name.ToString( ), false);

    just writing some trace to check why the function do not work...

    "Bela" <> дÈëÏûÏ¢
    news:...
    > Hello,
    >
    > I was wondering if someone could help me out with a Session_End problem in

    my Global.asax. I've tried everything, and still no success!
    > Here is the scenario: sessionstate is set to InProc. I have timeout set

    to 1 min.
    > I have a variable in session_start that is incremented each new session,

    and it is then decremented in Session_End. I use this variable on a web
    form to show current users online. All of this works just fine, so I know
    that session_end event handler is firing.
    > I also have the following in the Application_AuthenticateRequest

    handler:(This is an instance method that performs an update stored procedure
    in Sql Server 2000, and it also works fine)
    > Activity myActivity = new Activity( );
    > myActivity.Method(User.Identity.Name.ToString( ), true);
    >
    > Here's the prob: Session_end also contains this:
    > Activity myActivity = new Activity( );
    > myActivity.Method(User.Identity.Name.ToString( ), false);
    >
    > when the session timeout occurs after 1 min, this procedure does not work.

    What am I doing wrong? Please help. The decrementing of the variable works
    in session_end, why won't this?
    > Thank you in advance for any help on this subject.
    coollzh, Apr 13, 2004
    #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. Samuel Stanojevic
    Replies:
    1
    Views:
    932
    Samuel Stanojevic
    Sep 15, 2004
  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:
    796
    =?Utf-8?B?YmNoYXJsZXM=?=
    Oct 5, 2004
  3. Kim Bach Petersen
    Replies:
    5
    Views:
    15,709
    JamesJM
    Aug 3, 2011
  4. =?Utf-8?B?TWFubnkgQ2hvaGFu?=

    Session_end Global.asax

    =?Utf-8?B?TWFubnkgQ2hvaGFu?=, Aug 5, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    5,308
    =?Utf-8?B?U05ldW1hbm4=?=
    Sep 9, 2005
  5. Mark Rae

    Global.asax / Global.asax.cs in v2

    Mark Rae, May 23, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    3,136
    Mark Rae
    May 23, 2006
Loading...

Share This Page