Alex Rivera | Logout

ASP.NET | Forms Authentication | Get ALL logged in users(list of all users or count)

Asked 2009-10-30T13:41:19.267
9

I am using .NET 3.5. Also, Forms Authentication is used.

Is there any way to get the list of ALL logged-in users or a count in ASP.NET?

Note: I am not using Memberships and Roles

Edit
Report

2 Answers

7

No there isn't unless

  1. You have defined one in your own code

  2. You are using the default ASPNET Membership Provider which has a GetNumberOfUsersOnline() method defined.

  3. You are using a custom Membership Provider and have provided an implementation for the GetNumberOfUsersOnline() method yourself

The default ASPNET Membership provider calculates number of users online by querying the SQL Server database and checking the LastActivityDate stored against each user against the defined UserIsOnlineTimeWindow property that you can set in web.config. If the LastActivityDate is greater than the current time minus the UserIsOnlineTimeWindow value (which represents minutes), then a user is considered to be online.

If you wanted to do something similar then you might consider implementing a similar method. you can see the code for the default providers by downloading the source code. To complete your picture, you might also want to run aspnet_regsql.exe so that you can see the stored procedures that the default providers use.

answered 2009-10-30T13:45:06.403
1

I used Session_Start and Session_End under Global.aspx. it works most of times except the user close his/her browser. the server side needs to wait for the session expired to remove the user.

answered 2009-10-30T14:13:25.740

Your Answer