问题
After googling a bit I have found some tips about how to get online Users with ASP.NET. But I am using my own class for membership.
The information I have found is:
- Log the users sessionId to database when the user logs in
- Log them out when their session time out
What is your advice about this?
回答1:
I have found this great article
Hope helps someone
回答2:
We use this approach at work so that when users upload data in separate but concurrent session to a webservice, we can catch 90% of the cases where timeout has occurred and warn the user then and there.
We don't catch every case because:
- Session timeout event handler in global.asax isn't reliably called the moment expiration occurs (IIRC)
- The user could have closed their browser window in the mean time.
Two common approaches of which I am aware are:
- Any user action causes an update to LastActionTime in the users table. Using this value + 20 minutes (or whatever your session timeout value) is a pretty good indication of who is logged in
- A small AJAX panel updating every few seconds (linked with the previous option).
来源:https://stackoverflow.com/questions/454165/get-currently-online-users