Get currently online users?

◇◆丶佛笑我妖孽 提交于 2019-12-13 02:49:28

问题


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:

  1. Log the users sessionId to database when the user logs in
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!