i' m developing webapp in ASP.NET 2.0 (C#). I've problem to resolve issue.
The application should show users on-line, and only for administrator should show the user name. I'm using Application[] object to store usermame and count, setting the value in Globall.asax file.
In the following code i'll show the section relative to counter:
protected void Application_Start(object sender, EventArgs e){
Application["OnlineCounter"] = 0;
}
protected void Session_Start(Object sender, EventArgs e){
// Code that runs when a new session is started
if (Application["OnlineCounter"] != null){
Application.Lock();
Application["OnlineCounter"] = ((int)Application["OnlineCounter"]) + 1;
Application.UnLock();
}
}
protected void Session_End(Object sender, EventArgs e){
// Code that runs when a new session is started
if (Application["OnlineCounter"] != null){
Application.Lock();
Application["OnlineCounter"] = ((int)Application["OnlineCounter"]) - 1;
Application.UnLock();
}
}
Using this code on my local machine i can count correctly the online user. Instead, when i publish this code on server (Windows 2003 Server and IIS6) i found the following problem: accessing from my machine with 3 different user (using different browser), i will see only 1 user in a single page (In each browser i see only 1 online user) !
There are some issue for this ? Any suggestion is appreciated. Thanx