global.aspx and session_end event

G

Guest

When I call the session.abandon() method, it calls the session_end event.
When a user closes the browser or clicks the log off button, I can dispose
of objects and abandon the session cleaning. But, when a user either
navigates away from the web app and when the session timesout, the
session_end event does not seem to fire. Or when else can I dispose of
objects? Or is there an event I can you that is fired when a user navigates
away from the web app?
 
M

mnichols

After 20 minutes or whatever your IIS session timeout variable is the session_end event should be called.
If doesn't seem to be be working then check your IIS settings.

mnichols
 
G

Guest

found out, the event is being called, but I want to dispose (or clean up)
objects that was used within the web app. put the call within a try and wrote
to a event viewer. But, when I call the dispose method, it returned that the
"Object reference not set to an instance of an object." But, it did not
really release cleanly. Cause if user clicks on the Log off button on the web
app, it will call the dispose method and it shut down all dependent objects.
Any ideas around this?
 
M

mnichols

Sounds like a garbage collection issue. Somehow you need to determine if the objects have already been released or not and then when they are released that they are released completely.
The LogOff button should trigger a Session.Abandon which is what session_end should do. If there are subtle differences then I am sot sure I can help.
Maybe someone else has beeter insights.

mnichols
 
G

Guest

yes, my logoff functionality is working. What I am trying to do if if user
just navigates away from the web app without clicking the log off button.
Cannot always assume the users is going to follow instructions to the dot.
so, when the session timeouts, it does call the session_end event, but, does
not dispose of my objects cleanly. And that is what I am trying to figure out
now. Hope you or someone might have some insight.
 
K

Kumar Reddi

From what I understand with the discussion until now, you have some
code that cleans up your objects in user logoff function, but the same
code is not working if you place it in Session_End event handler. Is
that right?

If not, If users are simply navigating away from your application
without clicking logoff, how are you handling the object cleanup?
Remember server has no idea as what user does on the browser, unless he
sends a HTTP request

P.S: Session_End would not have access to HTTP request and response
handlers
 
G

Guest

From what I understand with the discussion until now, you have some
code that cleans up your objects in user logoff function, but the same
code is not working if you place it in Session_End event handler. Is
that right?
That is correct. If they navigate away, the session_end event is called when
the session has timed out. But, in the function, when I attempt to call the
dispose method of the object, it throws an error "Object reference not set to
an instance of an object." But, I know it did not dispose properly cause when
the object is called it starts a process inthe task manager I can monitor. If
I press the log off button, I see the process clear out of the task manager.
But, if the timeout is fired, the process is still running on the task
manager.
 
M

Mark Rae

That is correct. If they navigate away, the session_end event is called
when
the session has timed out. But, in the function, when I attempt to call
the
dispose method of the object, it throws an error "Object reference not set
to
an instance of an object." But, I know it did not dispose properly cause
when
the object is called it starts a process inthe task manager I can monitor.
If
I press the log off button, I see the process clear out of the task
manager.
But, if the timeout is fired, the process is still running on the task
manager.

See Peter's reply...

Do the following:

1) Set your Session timeout to 1 minute

2) Set a breakpoint at the very top of your Session_End method

3) Start your web project in debug mode (Ctrl-F5)

4) FROM ANOTHER BROWSER WINDOW, access your site

5) Log in as normal

6) Don't log out cleanly - instead, just close the browser

7) Wait patiently for 60 seconds until the Session_End fires - now step
through, identify the problem and fix it... :)
 

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

Similar Threads

Session_End 4
Testing if session_end fires 0
Session_End 2
Session_End event, System.NullReferenceException 1
Session_Start/Session_End 3
Session_End() 1
Session_End 14
detecting session timeout in Session_End 0

Members online

Forum statistics

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

Latest Threads

Top