There are a few ways you can approach this. One is to track users using global.asax and an application variable.
Add Global.asax file to your website / web application.
------------
C# Code :
------------
protected void Application_Start(object sender, EventArgs e)
{
Application["SessionCount"] = 0;
}
protected void Session_Start(object sender, EventArgs e)
{
Application.Lock();
Application["SessionCount"] = Convert.ToInt32(Application["SessionCount"]) + 1;
Application.UnLock();
}
protected void Session_End(object sender, EventArgs e)
{
Application.Lock();
Application["SessionCount"] = Convert.ToInt32(Application["SessionCount"]) - 1;
Application.UnLock();
}
----------------
VB.Net Code :
----------------
Protected Sub Application_Start(sender As Object, e As EventArgs)
Application("SessionCount") = 0
End Sub
Protected Sub Session_Start(sender As Object, e As EventArgs)
Application.Lock()
Application("SessionCount") = Convert.ToInt32(Application("SessionCount")) + 1
Application.UnLock()
End Sub
Protected Sub Session_End(sender As Object, e As EventArgs)
Application.Lock()
Application("SessionCount") = Convert.ToInt32(Application("SessionCount")) - 1
Application.UnLock()
End Sub
Then, in any page you can get current count of number of users:
<asp:Label ID="CounterLabel" runat="server"
Text='<% Response.Write("Current session count: " + Application["SessionCount"]) %>' />