Last post Jan 12, 2011 12:32 AM by cnranasinghe
Feb 01, 2008 01:56 PM|gopalanmani|LINK
Thanks for Advance
Feb 01, 2008 02:06 PM|tekhado|LINK
You can use, Global.asax file's event to check who is online. You need to create Application variable and store array of user's Id or Name in Session_Start Event. and retrive it when you want it.
To remove the user from list, you need to handle Session_End event of global.asax. But this option will deal with all users how has hit your application.
If your application have login page and you want to show only those users who are log in to your system then you have to set Application Variable in your Login page's code behind.
Feb 01, 2008 11:50 PM|dharnendra|LINK
Hi, you can use HASH Table to store the online viewers details.
Feb 04, 2008 04:05 AM|Punithkumar|LINK
1. In this page, set a variable LastVisitTime to store the last time the user visiting this page.
2. Use AJAX Timer, and every interval you can update database about the LastVisitTime of this user.
protected void Timer1_Tick(object sender, EventArgs e)
sql.update(update membertable set lastvisittime='" +DateTime.Now+ "' where username='" +User.Name+ "'");
3. Set the variable offVisitTime to check if this user is visiting the page.
DateTime lastvisit = Convert.ToDateTime(sql.select("select lastvisittime from membertable where username='" +User.Name+ "'"));
TimeSpan tSpanDifferent =DateTime.Now-lastvisit;
If(tSpanDifferent>SpanSpace)//SpanSpace is the variable which is the time span to chech if the user is off-visiting. And you can set it.
//The user is not visiting this page
For example, you can set Timer Interval as 2 minutes and set SpanSpace as 5 minutes.
4. After that, you can get the number of visiting users and who is visiting the page via looping.
Feb 04, 2008 04:07 AM|Punithkumar|LINK
To get number of users online..
Application("visitors_online") = 0
Session.Timeout = 20 '20 minute timeout
Application("visitors_online") = Application("visitors_online") + 1
Application("visitors_online") = Application("visitors_online") - 1
On line users: <%=Application("visitors_online")%>
Feb 04, 2008 07:33 AM|anas|LINK
if you are using the membership service,
use this code :
Dim OnlineUsers As New MembershipUserCollection
For Each user As MembershipUser In Membership.GetAllUsers
If user.IsOnline Then
' here you can access the onlineUsers collection
Feb 09, 2008 12:55 AM|satender88|LINK
I also want the same fuction. but I am using VB and created a own registration process in SQL Server 2005
sql cache dependency
Feb 11, 2008 01:22 AM|Punithkumar|LINK
U can convert VB code to c# code using this link..(Vice versa)
Jan 11, 2011 03:08 AM|SuHlaing|LINK
I also want to get the number of online active user. When I try to implement as you mentioned, I got the error like that.
"System.Web.HttpApplication.Application' is a 'property' but is used like a 'method"
I am quite new to asp.net so I don't know how to solve it. I would be much appreciate for any help.
Jan 11, 2011 06:26 AM|Miodrag Zivkovic|LINK
In C# you should use:
Jan 11, 2011 09:33 PM|SuHlaing|LINK
I got it and Thanks for your reply. However I haven't solved my issue.
Even I use the above coding, I didn't get the number of online users.
I mean Once I open the website, session _start event fire and I got online user count is 1.
If I open the website again via new browser, online user count is not increased . it is still 1.
I want to count the online user which is using my website. Any help/suggestion would be much appreciated.
Thanks and regards
Jan 12, 2011 12:32 AM|cnranasinghe|LINK