jeevacl
jeevacl

Reputation: 109

get number of user in online in asp.net application

I am developing a matrimonial web application in asp.net. In that I want to display number of users in online (logged in).

I am planning to maintain a "login-status table" in dB. And will maintain the table every time the user have logged in and out. But there is problem if the user have closed the browser directly without logging out.

Is there any other easy way to achieve this. Pleas provide sample code.

And I want to know how can I update the table that if the user click the browser's close button.

Upvotes: 0

Views: 195

Answers (1)

Iain
Iain

Reputation: 11244

I recently implemented something similar. The challenge I had is what defines "online". What if the user walks away from the computer, closes the browser, network is disconnected?

In the end I went with online means visited a page in the last 15 minutes. It avoids the issues with trying to detect when they walk away from the browser, or close it.

I did consider binding to the browsers onclose event and hitting a /user/closed/browser url. I have used that before in a call center website to unlock the call. But really the 15 minute rule was "good enough".

I coded it by keeping an in memory dictionary that I persisted to db every 5 minutes. Sorry I have no code to provide.

Upvotes: 1

Related Questions