473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

2.0: implementing users' counting with global.asax

Please help.
I try to implement counting of apllication users using global.asax
this way:

<script runat="server">
void Application_OnStart(object sender, EventArgs e)
{
Application.Add("Użytkownicy", 0);
}
void Application_OnEnd(object sender, EventArgs e)
{
Application.Remove("Użytkownicy");
}
void Session_OnStart(object sender, EventArgs e)
{
Application.Lock();
Application["Użytkownicy"] =
Convert.ToInt32(Application["Użytkownicy"]) + 1;
Application.UnLock();
}
void Session_OnEnd(object sender, EventArgs e)
{
Application.Lock();
Application["Użytkownicy"] =
Convert.ToInt32(Application["Użytkownicy"]) - 1;
Application.UnLock();
}
</script>

Unfortunatelly it does not work because Session OnStart/OnEnd and even
Application OnStart/OnEnd are called more often than I thought. For
Session_OnEnd/Session_OnStart instance it's sometimes called when
another page is selected from sitemap menu.
Do you know how to programme it?
Thank you very much.
/RAM/
Jun 14 '06 #1
1 1329
that is a glich in your code, because Session.OnStart only fires when a New
Session is required from the user, or everytime that timesout and need to
set a new one

Application_Onstart you need to stop and start the server so that can be
fired

if you do not own the server, just add to the Session_OnStart

if isNumeric(application("howmany")) then
application("howmany") += 1
else
application("howmany") = 0
end if
--

Bruno Alexandre
(a Portuguese in Křbenhanv, Danmark)
"R.A.M." <r_********@poczta.onet.pl> escreveu na mensagem
news:oi********************************@4ax.com...
Please help.
I try to implement counting of apllication users using global.asax
this way:

<script runat="server">
void Application_OnStart(object sender, EventArgs e)
{
Application.Add("Użytkownicy", 0);
}
void Application_OnEnd(object sender, EventArgs e)
{
Application.Remove("Użytkownicy");
}
void Session_OnStart(object sender, EventArgs e)
{
Application.Lock();
Application["Użytkownicy"] =
Convert.ToInt32(Application["Użytkownicy"]) + 1;
Application.UnLock();
}
void Session_OnEnd(object sender, EventArgs e)
{
Application.Lock();
Application["Użytkownicy"] =
Convert.ToInt32(Application["Użytkownicy"]) - 1;
Application.UnLock();
}
</script>

Unfortunatelly it does not work because Session OnStart/OnEnd and even
Application OnStart/OnEnd are called more often than I thought. For
Session_OnEnd/Session_OnStart instance it's sometimes called when
another page is selected from sitemap menu.
Do you know how to programme it?
Thank you very much.
/RAM/

Jun 14 '06 #2

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

Similar topics

22
by: fd123456 | last post by:
Hi Tom ! Sorry about the messy quoting, Google is playing tricks on me at the moment. > Global.asax is where you normally have the Global Application > and Session variables and code to...
5
by: Homer J. Simpson | last post by:
Hi, Any idea to get the -REAL- number of active users -WITHOUT- this kind of code ? ---------------------------------------------------------------------------- --------- Sub Session_OnStart...
5
by: ad | last post by:
The Global.asax is code-inside with default. How to change Global.asax to code-behind?
11
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...
8
by: Brendon Bezuidenhout | last post by:
Hey all, Newbie question I'm afraid: Is there a way to see/tell how many users are currently logged into a website at all? Thanks Brendon
16
by: thefritz_j | last post by:
We just converted our VS2003 1.1 VB web project (which was working fine) to VS2005 2.0 and now I get: Parser Error Message: Could not load type '<Namespace>.'. Source Error: Line 1: <%@...
8
by: Rob T | last post by:
When I was using VS2003, I was able to compile my asp.net project locally on my machine and copy it to the production server and it would run just fine. I've now converted to VS2005. The project...
15
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
by: Bjorn Sagbakken | last post by:
The subject says it all, more or less. With sessionState mode=InProc in web.config this works fine, using this approach in the global.asax: In the session_start event the count up:...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.