Click here to Skip to main content
15,894,740 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing a Web TV and Video Streaming Portal and that can be accessed only by registered users. Now I want to check the list of online/offline users saved in database. A user don't need to move across the pages as by watching TV channel or video for long duration. So I think the last activity time would not be helpful. I used the global.asax, by utilizing the Session_Start and Session_End events. But here I need to put the session TimeOut time but Unfortunately I Can't use it as the User Can sit to watch Movie or TV channel for long time...
I searched across all the forums but failed to find the solution. Do I need to ping the mac or ip address or something like this? Please help me.
Posted
Comments
JoCodes 23-Dec-13 3:37am    
Can use a asp.net user membership for the same and can be retrieved by Membership.GetUser("UserName").IsOnline
Zahid Khan Kakar 23-Dec-13 10:26am    
Can you please help me how to use the ASP membership. I am using cookies to switch user id between pages after user logged in.
JoCodes 23-Dec-13 10:57am    
Have added as a solutions . Can you please check and revert?

Consider the Comment from the OP adding how to use membership providers as well as to check users online.

- Add and Configure the Asp.net Membership provider to the application .This will add the necessary stored procedures and the tables which can be used directly. Can refer below.

http://mahedee.blogspot.in/2012/06/aspnet-membership-step-by-step.html[^]

- Now we are ready to use the MembershipUser.IsOnline() property as
http://msdn.microsoft.com/en-us/library/system.web.security.membershipuser.isonline(v=vs.110).aspx[^]

or Membership.GetNumberOfUsersOnline to get the number of online users

- Just in case if not working as expected a workaround can be tried
as below links

http://stackoverflow.com/questions/10151053/membershipuser-isonline-always-returns-false[^]

http://msdn.microsoft.com/en-us/library/system.web.security.membership.userisonlinetimewindow.aspx[^]

Now, without using asp.net membership provider I found this in the net . But not sure about it , may be you can have a try on this too .

http://code.msdn.microsoft.com/CSASPNETCurrentOnlineUserLi-0483a7f3[^]

Hope this helps...
 
Share this answer
 
Alright My friend,

I may not be able to give you any example code since ASP.NET is not (till now) my language. But I can provide you with a simple idea. It will definitely help and is also based on client-side scripting and I guess a very little server-side scripting is required that you are very good at :)

Here's my idea:

1. Use what I call a heartbeat.

2. I mean, a simple client-side javascript will generate a kind of ping message which will include user ID and will ping on the server on some ASP.Net script that you will create to receive the pings.

3. You have to use setTimeOut function of javascript to make a recursive call to a javascript function which will use AJAX to ping the server (I simply mean posting the data to your ASP.Net script).

4. The script will use the user ID and some security code (just to protect false ping) to keep update the database entry called isOnline to boolean true.

5. The timeout between each ping is decided by you so as to not put much burden on server as well as client bandwidth and CPU.

Hope that this response will give you some pointer to move ahead :) Please do rate my answer and you can also mark it as solved if it really solved your problem :)

With Regards
Tushar Srivastava
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900