Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When the user leaves the application 1

Status
Not open for further replies.

lunargirrl

Programmer
Jan 26, 2004
77
BR
Hello :)

When my users log-in I record in a table the date, time and the string "logged user".
I would like to record in table when the user leaves my application, either closing by webcontrol or by browser. Is there a way to make asp.net recognize when the user left the application and take those values to insert into a table?

tia,
venus
 
This isn't possible -- they could use the "terminate task" button on the task manager to kill the IExplore.exe process, and you wouldn't get any more info from them. So, there's no event that gets raised when the user closes their browser. Sorry.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
You could use the Global.asax file.
There is a function that fires when a User Session starts and when a User Session ends:

You could put the code in the Session_End routine:


Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)

' Fires when the session ends
' update database with current time

End Sub

 
But like chiph pointed out, that event isn't going to get raised when the browser is closed, but rather when the session times out.

I use this type of scenario for something in a few apps, and it doesn't work 100% of the time, so you have to keep that list of users cleaned out periodically, as well, if you want it to be nearly accurate (It's never going to be perfect).

-p

penny.gif
penny.gif

The answer to getting answered -- faq855-2992
 
link 9 and the other guys, thanks once again

I placed code in my session_end (an insert into in my db), it works fine every time i call the session.abandon, but when i close the app. by browser as i pointed before, it doesnt work, i'd like to know if it takes a time to insert the data in the db (the time of the session expiring) or it doesnt work at all.
if I have to wait certain minutes to have my data in the db, how can i reduce that time?

:**** thankalot
venus

 
Hi
The session end event fires when
1. You force a session.abandon through code
2. You do something like iisreset.
2. The session times out - the time taken to do this is in the web.config file. If you reduce this time, you might acheive what you are looking for. However, the downside is that if you are using session management for anything else (eg storing information) then that will be affected.

Hope this helps.

Mark [openup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top