Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 12, 2011 04:32 AM by cnranasinghe
Feb 01, 2008 05:56 PM|LINK
Thanks for Advance
Feb 01, 2008 06:06 PM|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 02, 2008 03:50 AM|LINK
Hi, you can use HASH Table to store the online viewers details.
Feb 04, 2008 08:05 AM|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 08:07 AM|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 11:33 AM|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 04:55 AM|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 05:22 AM|LINK
U can convert VB code to c# code using this link..(Vice versa)
Jan 11, 2011 07:08 AM|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 10:26 AM|LINK
In C# you should use: