tags:

views:

161

answers:

2

How do i keep checking if a user still is active, for like every 1 minute? I need to know which user is currently active and who is not! I'm not using ASP.NET membership provider!

Lets say, maximum 3 log in are allowed for one user to log in simultaneously from 3 different locations, if the same user, which is the 4th log in, try to log in from another location again, i would like to block the 4th log in.

I have few issues regarding this as well! If the user unplug the connection cable or close the browser, how do i figure out if the user is still active?

+4  A: 

I would need more detail about exactly what you are trying to accomplish, as you have asked a fairly vague question. However, I would think the best way to determine if a user is active is to check if their ASP.NET session is still alive. There is no "accurate" way to test if a user is still browsing your site, because they could be sitting there reading, or be AFK, or be in another program on their computer...dozens, if not hundreds of scenarios could exist on the client side.

However, the user's ASP.NET session will only live for a specific period of time between each activity from the user (GET, POST, etc.) Usually after 20 minutes, ASP.NET will clean up the users session, and when it does, it will fire a Session_End event that can be handled either in Global.asax, or with a custom HttpModule. You would then be able to flag that user as inactive in your own database, send an email, or do whatever it is you need to do.

jrista
thanks for your answer anyway! i found my own solution!!
WeeShian
A: 

Hi,

You can use the HttpResponse.IsClientConnected property to check if the user is still conncted to the session. For details see this --> http://msdn.microsoft.com/en-us/library/system.web.httpresponse.isclientconnected.aspx

Alternatevely, you can set a counter at Session_OnState at global.asax to check for the active session available and do your stuff based on that.

Bhaskar