Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 6th, 2009, 02:22 PM
Friend of Wrox
Points: 1,469, Level: 15
Points: 1,469, Level: 15 Points: 1,469, Level: 15 Points: 1,469, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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........
  #2 (permalink)  
Old December 6th, 2009, 03:52 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
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(); 
}
  #3 (permalink)  
Old December 7th, 2009, 09:14 AM
Friend of Wrox
Points: 1,469, Level: 15
Points: 1,469, Level: 15 Points: 1,469, Level: 15 Points: 1,469, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
  #4 (permalink)  
Old December 7th, 2009, 09:26 AM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
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(); 
}
  #5 (permalink)  
Old December 9th, 2009, 11:29 AM
Friend of Wrox
Points: 1,469, Level: 15
Points: 1,469, Level: 15 Points: 1,469, Level: 15 Points: 1,469, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
  #6 (permalink)  
Old December 14th, 2009, 01:27 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 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..
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:29 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.