Wrox Programmer Forums
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 6th, 2009, 02:22 PM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile online/offline status

Hello friends,
whenever I browse this forum one thing that strikes to mind is that how we can check that a particular user is online/offline.
that is whenever a user is logged in then he should be shown as online to other users' browser otherwise offline.
I did google for it but did not get much, hope I will have some idea here.
Thank You friends........
 
Old December 6th, 2009, 03:52 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

I assume you want to do this in .NET.

If so, you can use the Membership API. Briefly, here are the steps:

- Create a list to hold the online user's names.
- Call Membership.GetAllUsers to get all registered users.
- Loop through the result, checking each user's IsOnline property.
- If IsOnline = true. add them to the list you created in step 1.
- Return the list.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old December 7th, 2009, 09:14 AM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile

Hello, Thank you for your reply. But can you please explain first step Create a list to hold the online user's names. a little bit more, that is how to create it?
Thank you once again.
 
Old December 7th, 2009, 09:26 AM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

List<MembershipUser> onlineUsers = new List<MembershipUser>;
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old December 9th, 2009, 11:29 AM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile

sorry not to tell you earlier, I am using VB.NET
So can you please give a VB.NET snippet and also please tell me how to assign no. of users to the list created. (step 4)
Thank you and once again sorry.
 
Old December 14th, 2009, 01:27 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Here's a simple example of what Lee meant:

Code:
 
Imports System.Web.Security
...
Dim users As New List(Of String)
For Each myUser As MembershipUser In Membership.GetAllUsers()
  If myUser.IsOnline Then
    users.Add(myUser.UserName)
  End If
Next
Once this code is done, the users variable contains the names of on-line users.

Warning: with a large number of users this is likely to break. GetAllUsers has an overload that enables you to "page" your users which is a better alternative in terms of memory consumption and database locks.

You can also bypass the Membership API and use direct SQL to query just the names. Look in the Stored Procedures of a database using membership for some ideas on implementing this.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!

Last edited by Imar; January 15th, 2010 at 05:54 PM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Access DataGrid Control Offline s13khan C# 1 July 18th, 2006 08:35 PM
offline php scripts chayanvinayak PHP How-To 0 July 6th, 2006 01:35 PM
.ASP login page fails offline, but works online ?? putte74 Classic ASP Basics 1 January 10th, 2006 07:21 PM
The webpage you requested is not available offline cathiec ASP.NET 1.0 and 1.1 Basics 0 October 6th, 2005 09:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.