Whose online problem RRS feed

  • Question

  • User1902359598 posted
    Hi all,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>I'm using the Membership provider so I have all the various aspnet_membership, aspnet_user tables etc in my database. Now what I was trying to do is write my business/data objects so I could return a list of members, plus some extra details I hold on them, that are currently online to other users currently online. The problem is how do I know who is online?


    Firstly I tried using the LastLoginDate field in the aspnet_membership table and by using the SQL DataDiff() function I could calculate if the user logged in within the last 15 minutes (which is my logged in time window). Now although this did work it doesn't take into account the length of time the user is on the site so they may still be there after 15 minutes so when somewhere else searches for logged in users this user won't be returned even though they are still there. So I then changed it to the LastActivityDate field in the aspnet_Users table and this has the same problem (I couldn't not find any activity that automatically updated this field in any case - if that is what it is there for?). So now I'm thinking do I have to explicitly update this LastActivityDate field each time the user performs any action on my site just so I can keep an up to date record of who is online?


    Does anyone know an easy way of doing this? <o:p></o:p>

    Thanks for any help.

    Friday, January 11, 2008 11:20 AM


All replies

  • User1407569999 posted

    The MembershipUser has an IsOnline boolean property...

    Friday, January 11, 2008 11:42 AM
  • User1902359598 posted

    I am aware of that property but how would I use it with the database created by the Membership provider to return all members currently online and the additional information I hold on them? The point is I can't use that property in SQL, it can only be used within my .net code in my pages. The last thing I want to do is return every single user and then filter out those who are online by using that property as I'll be sending huge volumes of data back most of which I won't need as most members won't be online at any one time.

    Does anyone have any other suggestions?


    Friday, January 11, 2008 11:54 AM
  • User1407569999 posted

    Oh, sorry, I thought you wanted to see if a user was online.  Check out this blog post: http://www.andreas-kraus.net/blog/show-aspnet-membership-online-users/ -- has a stored proc and everything.   Real easy... you're right about the last activity date.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 11, 2008 12:06 PM
  • User1902359598 posted

    Blast!!! I was really hoping I was wrong about the activity date. Any way this is exactly what I needed, thanks for your help, much appreciated.

    Friday, January 11, 2008 12:12 PM
  • User1407569999 posted

    btw, http://msdn.microsoft.com/en-us/library/system.web.security.membershipuser.lastactivitydate.aspx -- the last activity date references the last authentication of the user.  The Membership.GetUser(true) will update this column.

    Friday, January 11, 2008 12:12 PM