i'm trying to show the number of users that visits website and the number of online users... i wrote this code in Global Application Class(.asax.cs)
protected void Application_Start(object sender, EventArgs e)
{
Application.Add("counter", 0);
Application.Add("onlineCounter", 0);
}
protected void Session_Start(object sender, EventArgs e)
{
Application.Lock();
int _counter = (int)Application["counter"];
_counter++;
Application["counter"] = _counter;
Application.UnLock();
Application.Lock();
int _onlineCounter = (int)Application["onlineCounter"];
_onlineCounter++;
Application["onlineCounter"] = _onlineCounter;
Application.UnLock();
}
protected void Session_End(object sender, EventArgs e)
{
Application.Lock();
int _onlineCounter = (int)Application["onlineCounter"];
_onlineCounter--;
Application["onlineCounter"] = _onlineCounter;
Application.UnLock();
}
the problem that face me ... when running the website for first time the value of visits = 1 and online users = 1 and never change after that even when i open another tabs of the website or refresh the website