RSS

ASP.NET Active User Count

Chris Filed Under:
Here is a quick and dirty way to track the number of active users on your site as a given time. This is implemented on SoccerXpert.com.

The implementation is simple just add the following code to the global.asax:


Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Application("ActiveSessionCount") = 0
End Sub

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Application("ActiveSessionCount") += 1
End Sub

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
Application("ActiveSessionCount") -= 1
End Sub

In your master page add a reference to the session variable:

Dim ActiveSessionCount as Integer = Application("ActiveSessionCount")

| edit post
Reactions: 

0 Responses to "ASP.NET Active User Count"