Problem with Session_End in Global.asax

G

Guest

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.
 
C

Cliff Harris

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 said:
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?
 
C

coollzh

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 said:
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?
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top