473,509 Members | 2,763 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem Reading Global.asax Variables

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

May 17 '07 #1
3 3267
Hi,
Below link should help you:
http://aspnet101.com/aspnet101/tutorials.aspx?id=16
--
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"Jack" wrote:
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
May 17 '07 #2
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

"Manish Bafna" <Ma*********@discussions.microsoft.comwrote in message
news:50**********************************@microsof t.com...
Hi,
Below link should help you:
http://aspnet101.com/aspnet101/tutorials.aspx?id=16
--
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"Jack" wrote:
>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
May 17 '07 #3
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


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Jack" <jo***@webfoxmail.comwrote in message
news:3D**********************************@microsof t.com...
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

May 17 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
5122
by: Sahil Malik [MVP] | last post by:
So here's a rather simple question. Say in an ASP.NET application, I wish to share common constants as static variables in global.asax (I know there's web.config bla bla .. but lets just say I...
5
3928
by: WJ | last post by:
I am attempting to use the Global.Asax to store my user's configuration. Here is the concept: 1. User logs on into the site using Form Authentication. 2. I capture the user Credential, verify it...
12
3798
by: John M | last post by:
Hello, On Microsoft Visual Studio .NET 2003, I want to use some global elements, that can be used in each one of my pages. i.e I put a oleDBConnection on global.asax.vb How can I use it...
2
5190
by: Nathan Sokalski | last post by:
I would like to access variables and functions that I declare in the Global.asax.vb file. However, I am having trouble doing that. What does the declaration have to look like in the Global.asax.vb...
2
1367
by: BookerW | last post by:
Ok, here is the situation. I have some vb code that was upgraded to the earliest asp, I believe. When i run this snippet of code below on my local xp box with iis and visual studio 2003...
11
8318
by: Ron | last post by:
I have a web project compiled with the new "Web Deployment Projects" plugin for VS2005. I'm deploying the web project to one assembly and with updateable option set to ON. When I'm running the...
5
2316
by: Nathan Sokalski | last post by:
I recently upgraded from Visual Studio .NET 2003 to Visual Studio .NET 2005. Visual Studio .NET 2005 does not create the Global.asax files that Visual Studio .NET 2003 did, which I used for...
15
2528
by: =?Utf-8?B?UGF0Qg==?= | last post by:
Just starting to move to ASP.NET 2.0 and having trouble with the Global.asax code file. In 1.1 I could have a code behind file for the global.asax file. This allow for shared variables of the...
0
7233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
7067
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5650
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
440
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.