MemberShip Count Online Users

Online html editor online JavaScript editorC# Online usersASp.net 2.0 step by step Membership Provider how to purchase onlineFree Online Eye TestLinq Group By Multiple ColumnsMembershipProvider Get user UniqekeySET NOCOUNT ONMembership ProviderRemove Gmail account from AndroidLinq Get Duplicate Count Of Words From StringMegaupload watch movies onlinePage view countFree Watch Movies online in HD quality From Official Channels.Tata Docomo online bill paymentAuto login for domain users single sign onGoogle Online calculator and other functionality to convert units.Paypal purpose code IndiaYahoo email settingsHow to use Google analyticsListBox Asp.net Binding csharpGmail Password ProtectionHack WiFi Networkhow to open a blog websiteWindows Password LostYouTube adsenseTemporary disposable emailHow to earn money with android phoneC# Get Random Item From List (VB.net) Example.Where is my IP locationC# while loop
MemberShip Count Online Users

 Some time we need to count the online users 

If you are new to ASP.net Membership provider,

please refer
http://www.revenmerchantservices.com/page/ASpnet-20-step-by-step-Membership-Provider-.aspx

Below code will count online users

C# Code
MembershipUserCollection uc = Membership.GetAllUsers();

    int count=0; 
  foreach(MembershipUser u in uc)
  {
     if(u.IsOnline)
      count++;
  }


VB Code

Dim uc As MembershipUserCollection = Membership.GetAllUsers()
Dim count As Integer = 0
For Each u As MembershipUser In uc
    If u.IsOnline Then
        count += 1
    End If
Next
You can bind the online user names to ListBox using below code

C# code

System.Collections.Generic.List<string> lstUser = new System.Collections.Generic.List<string>();


        MembershipUserCollection uc = Membership.GetAllUsers();
       
        foreach (MembershipUser u in uc)
        {
            if (u.IsOnline)
               
                lstUser.Add(u.UserName);

        }

        ListBox1.DataSource = lstUser;
        ListBox1.DataBind();


VB code

 System.Collections.Generic.List<string> lstUser = new System.Collections.Generic.List<string>();


        MembershipUserCollection uc = Membership.GetAllUsers();
       
        foreach (MembershipUser u in uc)
        {
            if (u.IsOnline)
               
                lstUser.Add(u.UserName);

        }

        ListBox1.DataSource = lstUser;
        ListBox1.DataBind();


Satalaj

Tags:

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
Satalaj More+

I'm Satalaj.