Have a look on following thread:
http://www.aspdotnetfaq.com/Faq/How-to-show-number-of-online-users-visitors-for-ASP-NET-website.aspx[
^]
Free hit counter[
^]
Write code in
global.asax file which interacts with the entire application.
The sample code is given below:
void Application_OnStart(Object Sender, EventArgs E)
{
Application["CurrentUsers"] = 0;
}
void Session_OnStart(object Sender, EventArgs E)
{
Application.Lock();
Application["CurrentUsers"] = System.Convert.ToInt32(Application["CurrentUsers"]) + 1;
Application.UnLock();
}
void Session_OnEnd(object Sender, EventArgs E)
{
Application.Lock();
Application["CurrentUsers"] = System.Convert.ToInt32(Application["CurrentUsers"]) - 1;
Application.UnLock();
}
Try this one:
global.asax
file for that like
void Application_Start(object sender, EventArgs e)
{
Application["OnlineUsers"]=0;
}
void Session_Start(object sender, EventArgs e)
{
Session["Users"] =Convert.ToInt32( Application["OnlineUsers"])+ 1;
Application["OnlineUsers"] = Session["Users"];
}
page load:
Response.Write(Session["Users"].ToString());