Home > ASP.Net > Get All Logged in Users using Membership

Get All Logged in Users using Membership


Hi all,

try this example to Get All logged in users using Membership :-

First Add Gridview Control in your page and in code behind add this code which will bind Gridview to Online Users :-

  ArrayList list = new ArrayList();
        MembershipUserCollection allUsers = Membership.GetAllUsers();
        MembershipUserCollection filteredUsers = new MembershipUserCollection(); 
        bool isOnline = true;
        foreach (MembershipUser user in allUsers)
        {
            // if user is currently online, add to gridview list
            if (user.IsOnline == isOnline)
            {
                filteredUsers.Add(user);
                list.Add(user);
            } 
            gvwonlineusers.DataSource = list;
            gvwonlineusers.DataBind();
        }

Hope this helps

Good Luck

Advertisements
Categories: ASP.Net
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: