Last post Apr 18, 2012 02:31 PM by House5
Apr 18, 2012 02:07 PM|House5|LINK
My question is how can I count how many visitors are online now in my webSite?
I wrote this code but this only show to me how many times I enter to the web.
void Application_Start(object sender, EventArgs e)
Application["counter"] = 0;
void Session_Start(object sender, EventArgs e)
Application["counter"] = (int)Application["counter"] + 1;
void Session_End(object sender, EventArgs e)
Application["counter"] = (int)Application["counter"] - 1;
Apr 18, 2012 02:09 PM|Sandeep Shenoy|LINK
you can do it using a database, i have provided with a member with codes before some weeks...please give me your email id..i can send it to you too..
Apr 18, 2012 02:18 PM|House5|LINK
Thank you :)
Apr 18, 2012 02:22 PM|amitpatel.it|LINK
Better option is add this count in Request_beginRequest in global.aspx file and also insert number in xml or database because if IIS restart then you will loss your that application variable. or you have to implement Auto-start web application feature if
you are working in iis 7.5
Apr 18, 2012 02:23 PM|ThaYoung1!|LINK
Maybe using Google Analytics is an option?
They have real-time visitor stats. Next to that there's lots of other information available.
Apr 18, 2012 02:25 PM|AccuWebHosting.Com|LINK
Try the following URLs for Code along with its explanation:
Show number of online users / visitors
Online active users counter in ASP.NET
Apr 18, 2012 02:27 PM|jamshed alam|LINK
Apr 18, 2012 02:31 PM|House5|LINK
I use this Url http://www.aspdotnetfaq.com/Faq/How-to-show-number-of-online-users-visitors-for-ASP-NET-website.aspx.
this is my Web.config code:
<add key="localhostCreditCardWebService.CreditCardWebService" value="http://localhost:50122/PayPalService/CreditCardWebService.asmx"/>
<add key="localhostMoviesService.MoviesService" value="http://localhost:50117/ImdbService/MoviesService.asmx"/>
<sessionState mode="InProc" cookieless="false" timeout="1" />
I changed the numbers 20 to 1 only for testing this more quicky.
unfortantly something wrong and I dont what it is.
Moreover I dont know where I need to put this code line:
Visitors online: <%= Application["OnlineUsers"].ToString() %>
that's how I view the number of users this work
this.LabelOnlineUsers.Text = "Users Online " + Application["counter"].ToString();