Problem Reading Global.asax Variables

J

Jack

Hello,

I am trying to add how many users online to my website. I have setup a
Global.asax and need some morehelp.

I have the following Global.asax

Public Class Global

Inherits System.Web.HttpApplication

Private Shared _CurrentNumberOfUsersOnline As Integer = 0

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)

End Sub

Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)

End Sub

Public Shared ReadOnly Property CurrentNumberOfUsersOnline() As Integer

Get

Return _CurrentNumberOfUsersOnline

End Get

End Property

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)

_CurrentNumberOfUsersOnline += 1

End Sub

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)

_CurrentNumberOfUsersOnline -= 1

End Sub

End Class



I need to be able to read the CurrentNumberOfUsersOnline via any page in a
web site.



Thanks,



For any help,



Jack
 
J

Jack

Hello,

I tried that and I get no errors, but the number never changes from 0.

Do you have any ideas?

I am using a Codebehind.

Thanks,

Jack
 
J

Juan T. Llibre

In which events in Global.asax are these code bits running ?

1.
Private Shared _CurrentNumberOfUsersOnline As Integer = 0

2.
Public Shared ReadOnly Property CurrentNumberOfUsersOnline() As Integer
Get
Return _CurrentNumberOfUsersOnline
End Get
End Property

3.
Public Shared ReadOnly Property CurrentNumberOfUsersOnline() As Integer
Get
Return _CurrentNumberOfUsersOnline
End Get
End Property

I don't see them running inside *any* event.
Try moving those bits of code to a global.asax event of your choice
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,061
Latest member
KetonaraKeto

Latest Threads

Top