By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,993 Members | 1,984 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,993 IT Pros & Developers. It's quick & easy.

What's the deal with Membership.GetNumberOfUsersOnline?

P: n/a
Hi there,

Membership.GetNumberOfUsersOnline() works great the first time, then
jumps up to the number of users registered in the system.

I have tried enumerating through each user individually and checking
IsOnline which done likewise, first result was 4, then 22 every time after
that and it's only be debugging locally using VS.

Either I'm doing something seriously wrong or this function is a
complete joke. I'm opting for the latter personally....

Any input on this would be greatly appreciated.

Nick.
Jul 30 '08 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Hi Nick,

From your description, you're encountering some problem when using
Membership.GetNumberOfUsersOnline API, correct?

According to your scenario, the number changed when you call it second
time. Based on my research, the GetNumberOfUsersOnline will be affected
when some of the following methods are called(from the MSDN document)

==================
The last-activity date/time stamp is updated to the current date and time
when user credentials are validated by way of the ValidateUser or
UpdateUser method or when a call to a GetUser overload that takes no
parameters or one that uses the userIsOnline parameter to specify that the
date/time stamp should be updated.
============

#Membership..::.GetNumberOfUsersOnline Method
http://msdn.microsoft.com/en-us/libr...mbership.getnu
mberofusersonline.aspx

Therefore, I wonder whehter any of the methods are called so that all the
users become activated before you call the GetNumberOfUsersOnline method
second time. You can also directly validate the database table's
"lastactiviated" field to verify the behavior.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: "Nick" <a@a.com>
Subject: What's the deal with Membership.GetNumberOfUsersOnline?
Date: Wed, 30 Jul 2008 13:58:18 +0100
>
Hi there,

Membership.GetNumberOfUsersOnline() works great the first time, then
jumps up to the number of users registered in the system.

I have tried enumerating through each user individually and checking
IsOnline which done likewise, first result was 4, then 22 every time after
that and it's only be debugging locally using VS.

Either I'm doing something seriously wrong or this function is a
complete joke. I'm opting for the latter personally....

Any input on this would be greatly appreciated.

Nick.
Jul 31 '08 #2

P: n/a
Hi Nick,

Any further quesiton on this issue?

Sincerely,

Steven Cheng
Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: st*****@online.microsoft.com (Steven Cheng [MSFT])
Organization: Microsoft
Date: Thu, 31 Jul 2008 02:24:17 GMT
Subject: RE: What's the deal with Membership.GetNumberOfUsersOnline?
>
Hi Nick,

From your description, you're encountering some problem when using
Membership.GetNumberOfUsersOnline API, correct?

According to your scenario, the number changed when you call it second
time. Based on my research, the GetNumberOfUsersOnline will be affected
when some of the following methods are called(from the MSDN document)

==================
The last-activity date/time stamp is updated to the current date and time
when user credentials are validated by way of the ValidateUser or
UpdateUser method or when a call to a GetUser overload that takes no
parameters or one that uses the userIsOnline parameter to specify that the
date/time stamp should be updated.
============

#Membership..::.GetNumberOfUsersOnline Method
http://msdn.microsoft.com/en-us/libr...embership.getn
u
>mberofusersonline.aspx

Therefore, I wonder whehter any of the methods are called so that all the
users become activated before you call the GetNumberOfUsersOnline method
second time. You can also directly validate the database table's
"lastactiviated" field to verify the behavior.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

p
Aug 4 '08 #3

P: n/a
Hi Steven,

Sorry for the delayed reply, I've got several threads running at the
same time trying to do too much at once LOL!

The users are only being enumerated in one point and that's the
additional function i've made to count the number of users currently online,

---

int pIntCurCount = 0;
MembershipUserCollection pMUCUsers = Membership.GetAllUsers();
foreach (MembershipUser pMUrUser in pMUCUsers)
{
pIntCurCount += (pMUrUser.IsOnline ? 1 : 0);
}
lblUsersOnline.Text = String.Format("Users Online : {0} - ",
pIntCurCount.ToString());

---

This consistently produces the correct number the first time it is run,
then returns the total number of users the second time round. So it seems
that GetAllUsers must be modifying the flag as you suggest, but then that
just raises the question of how this could possibly be achieved other than
enumerating the database manually which imo, is nasty and shouldn't need to
be done.

So surely GetNumberOfUsersOnline is buggy? It doesn't produce a
consistently correct value, so must be surely?

More to the point, why is the users last logged in date changed at all
during any of these calls? Why not leave it down to the user to update the
value via a manual invocation of an update method. If this is the correct
behaviour, it is pretty poor unfortunately.

Nick.

"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:j2**************@TK2MSFTNGHUB02.phx.gbl...
Hi Nick,

From your description, you're encountering some problem when using
Membership.GetNumberOfUsersOnline API, correct?

According to your scenario, the number changed when you call it second
time. Based on my research, the GetNumberOfUsersOnline will be affected
when some of the following methods are called(from the MSDN document)

==================
The last-activity date/time stamp is updated to the current date and time
when user credentials are validated by way of the ValidateUser or
UpdateUser method or when a call to a GetUser overload that takes no
parameters or one that uses the userIsOnline parameter to specify that the
date/time stamp should be updated.
============

#Membership..::.GetNumberOfUsersOnline Method
http://msdn.microsoft.com/en-us/libr...mbership.getnu
mberofusersonline.aspx

Therefore, I wonder whehter any of the methods are called so that all the
users become activated before you call the GetNumberOfUsersOnline method
second time. You can also directly validate the database table's
"lastactiviated" field to verify the behavior.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
>>From: "Nick" <a@a.com>
Subject: What's the deal with Membership.GetNumberOfUsersOnline?
Date: Wed, 30 Jul 2008 13:58:18 +0100
>>
Hi there,

Membership.GetNumberOfUsersOnline() works great the first time, then
jumps up to the number of users registered in the system.

I have tried enumerating through each user individually and checking
IsOnline which done likewise, first result was 4, then 22 every time after
that and it's only be debugging locally using VS.

Either I'm doing something seriously wrong or this function is a
complete joke. I'm opting for the latter personally....

Any input on this would be greatly appreciated.

Nick.

Aug 6 '08 #4

P: n/a
Hi Nick,

Per the document, the method call on "MembershipUser.IsOnline" may update
its online status. Therefore, I suggest you try calling
"Membership.GetNumberOfuserOnline" several times without accessing each
user's IsOnline property(remove the foreach loop). I think it will make the
"Membership.GetNumberOfuserOnline" call return the consistent result.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Nick" <a@a.com>
References: <#Q**************@TK2MSFTNGP05.phx.gbl>
<j2**************@TK2MSFTNGHUB02.phx.gbl>
>Subject: Re: What's the deal with Membership.GetNumberOfUsersOnline?
Date: Wed, 6 Aug 2008 13:40:40 +0100
>
Hi Steven,

Sorry for the delayed reply, I've got several threads running at the
same time trying to do too much at once LOL!

The users are only being enumerated in one point and that's the
additional function i've made to count the number of users currently
online,
>
---

int pIntCurCount = 0;
MembershipUserCollection pMUCUsers = Membership.GetAllUsers();
foreach (MembershipUser pMUrUser in pMUCUsers)
{
pIntCurCount += (pMUrUser.IsOnline ? 1 : 0);
}
lblUsersOnline.Text = String.Format("Users Online : {0} - ",
pIntCurCount.ToString());

---

This consistently produces the correct number the first time it is
run,
>then returns the total number of users the second time round. So it seems
that GetAllUsers must be modifying the flag as you suggest, but then that
just raises the question of how this could possibly be achieved other than
enumerating the database manually which imo, is nasty and shouldn't need
to
>be done.

So surely GetNumberOfUsersOnline is buggy? It doesn't produce a
consistently correct value, so must be surely?

More to the point, why is the users last logged in date changed at all
during any of these calls? Why not leave it down to the user to update
the
>value via a manual invocation of an update method. If this is the correct
behaviour, it is pretty poor unfortunately.

Nick.

"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:j2**************@TK2MSFTNGHUB02.phx.gbl...
>Hi Nick,

From your description, you're encountering some problem when using
Membership.GetNumberOfUsersOnline API, correct?

According to your scenario, the number changed when you call it second
time. Based on my research, the GetNumberOfUsersOnline will be affected
when some of the following methods are called(from the MSDN document)

==================
The last-activity date/time stamp is updated to the current date and time
when user credentials are validated by way of the ValidateUser or
UpdateUser method or when a call to a GetUser overload that takes no
parameters or one that uses the userIsOnline parameter to specify that
the
>date/time stamp should be updated.
============

#Membership..::.GetNumberOfUsersOnline Method
http://msdn.microsoft.com/en-us/libr...mbership.getnu
>mberofusersonline.aspx

Therefore, I wonder whehter any of the methods are called so that all the
users become activated before you call the GetNumberOfUsersOnline method
second time. You can also directly validate the database table's
"lastactiviated" field to verify the behavior.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you.
Please
>feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

================================================= =
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
>ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
>where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
>up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
================================================= =
This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
>>>From: "Nick" <a@a.com>
Subject: What's the deal with Membership.GetNumberOfUsersOnline?
Date: Wed, 30 Jul 2008 13:58:18 +0100
>>>
Hi there,

Membership.GetNumberOfUsersOnline() works great the first time, then
jumps up to the number of users registered in the system.

I have tried enumerating through each user individually and checking
IsOnline which done likewise, first result was 4, then 22 every time
after
>>>that and it's only be debugging locally using VS.

Either I'm doing something seriously wrong or this function is a
complete joke. I'm opting for the latter personally....

Any input on this would be greatly appreciated.

Nick.


Aug 7 '08 #5

P: n/a
Hi Steven

No it won't you, have completely misunderstood. I wrote that method as
an alternative to GetNumberOfUsersOnline, neither of which produce
consistent results.

In fact, that code sample doesn't even have a call to
GetNumberOfUsersOnline in it.

Nick.

"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:$8******************@TK2MSFTNGHUB02.phx.gbl.. .
Hi Nick,

Per the document, the method call on "MembershipUser.IsOnline" may update
its online status. Therefore, I suggest you try calling
"Membership.GetNumberOfuserOnline" several times without accessing each
user's IsOnline property(remove the foreach loop). I think it will make
the
"Membership.GetNumberOfuserOnline" call return the consistent result.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
>>From: "Nick" <a@a.com>
References: <#Q**************@TK2MSFTNGP05.phx.gbl>
<j2**************@TK2MSFTNGHUB02.phx.gbl>
>>Subject: Re: What's the deal with Membership.GetNumberOfUsersOnline?
Date: Wed, 6 Aug 2008 13:40:40 +0100
>>
Hi Steven,

Sorry for the delayed reply, I've got several threads running at the
same time trying to do too much at once LOL!

The users are only being enumerated in one point and that's the
additional function i've made to count the number of users currently
online,
>>
---

int pIntCurCount = 0;
MembershipUserCollection pMUCUsers = Membership.GetAllUsers();
foreach (MembershipUser pMUrUser in pMUCUsers)
{
pIntCurCount += (pMUrUser.IsOnline ? 1 : 0);
}
lblUsersOnline.Text = String.Format("Users Online : {0} - ",
pIntCurCount.ToString());

---

This consistently produces the correct number the first time it is
run,
>>then returns the total number of users the second time round. So it seems
that GetAllUsers must be modifying the flag as you suggest, but then that
just raises the question of how this could possibly be achieved other than
enumerating the database manually which imo, is nasty and shouldn't need
to
>>be done.

So surely GetNumberOfUsersOnline is buggy? It doesn't produce a
consistently correct value, so must be surely?

More to the point, why is the users last logged in date changed at all
during any of these calls? Why not leave it down to the user to update
the
>>value via a manual invocation of an update method. If this is the correct
behaviour, it is pretty poor unfortunately.

Nick.

"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:j2**************@TK2MSFTNGHUB02.phx.gbl.. .
>>Hi Nick,

From your description, you're encountering some problem when using
Membership.GetNumberOfUsersOnline API, correct?

According to your scenario, the number changed when you call it second
time. Based on my research, the GetNumberOfUsersOnline will be affected
when some of the following methods are called(from the MSDN document)

==================
The last-activity date/time stamp is updated to the current date and
time
when user credentials are validated by way of the ValidateUser or
UpdateUser method or when a call to a GetUser overload that takes no
parameters or one that uses the userIsOnline parameter to specify that
the
>>date/time stamp should be updated.
============

#Membership..::.GetNumberOfUsersOnline Method
http://msdn.microsoft.com/en-us/libr...mbership.getnu
>>mberofusersonline.aspx

Therefore, I wonder whehter any of the methods are called so that all
the
users become activated before you call the GetNumberOfUsersOnline
method
second time. You can also directly validate the database table's
"lastactiviated" field to verify the behavior.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments
and
suggestions about how we can improve the support we provide to you.
Please
>>feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

================================================ ==
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
>>ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
>>where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
>>up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach
the
most efficient resolution. The offering is not appropriate for
situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are
best
handled working with a dedicated Microsoft Support Engineer by
contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
================================================ ==
This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
From: "Nick" <a@a.com>
Subject: What's the deal with Membership.GetNumberOfUsersOnline?
Date: Wed, 30 Jul 2008 13:58:18 +0100
Hi there,

Membership.GetNumberOfUsersOnline() works great the first time, then
jumps up to the number of users registered in the system.

I have tried enumerating through each user individually and checking
IsOnline which done likewise, first result was 4, then 22 every time
after
>>>>that and it's only be debugging locally using VS.

Either I'm doing something seriously wrong or this function is a
complete joke. I'm opting for the latter personally....

Any input on this would be greatly appreciated.

Nick.




Aug 8 '08 #6

P: n/a
Thanks for your reply Nick,

I have performed some local tests(using the default SQLExpress membership
provider). Here is a test page I used two buttons to simulate two methods
to check Users online:
==============================
public partial class status : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
foreach (MembershipUser user in Membership.GetAllUsers())
{
Response.Write("<br/>" + user.UserName + ": " + user.IsOnline);
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Label1.Text = "Users Online: " +
Membership.GetNumberOfUsersOnline().ToString();
}
}
======================

It seems the result will keep the same when I press the button multiple
times. BTW, if you have created a new user via "createUserWizard" , the
user may be set to online status. You may need to logout first(also it may
take some time to make it take effect due to the delay used for the
membership to calculate the expire).

for your scenario, do you mean if you click such button multiple times, it
will return different results?

Sincerely,

Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Nick" <a@a.com>
References: <#Q**************@TK2MSFTNGP05.phx.gbl>
<j2**************@TK2MSFTNGHUB02.phx.gbl>
<#Q**************@TK2MSFTNGP06.phx.gbl>
<$8**************@TK2MSFTNGHUB02.phx.gbl>
>Subject: Re: What's the deal with Membership.GetNumberOfUsersOnline?
Date: Fri, 8 Aug 2008 13:43:10 +0100
>
Hi Steven

No it won't you, have completely misunderstood. I wrote that method
as
>an alternative to GetNumberOfUsersOnline, neither of which produce
consistent results.

In fact, that code sample doesn't even have a call to
GetNumberOfUsersOnline in it.

Nick.

"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:$8******************@TK2MSFTNGHUB02.phx.gbl. ..
>Hi Nick,

Per the document, the method call on "MembershipUser.IsOnline" may update
its online status. Therefore, I suggest you try calling
"Membership.GetNumberOfuserOnline" several times without accessing each
user's IsOnline property(remove the foreach loop). I think it will make
the
"Membership.GetNumberOfuserOnline" call return the consistent result.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

Aug 11 '08 #7

P: n/a
Hi Steven,

I have found the problem, further down in the code there is an offending
GetUser call, this has been fixed and now the problem is resolved. Thanks a
million for your time, it's been most appreciated.

Nick.

"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:ZI****************@TK2MSFTNGHUB02.phx.gbl...
Thanks for your reply Nick,

I have performed some local tests(using the default SQLExpress membership
provider). Here is a test page I used two buttons to simulate two methods
to check Users online:
==============================
public partial class status : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
foreach (MembershipUser user in Membership.GetAllUsers())
{
Response.Write("<br/>" + user.UserName + ": " + user.IsOnline);
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Label1.Text = "Users Online: " +
Membership.GetNumberOfUsersOnline().ToString();
}
}
======================

It seems the result will keep the same when I press the button multiple
times. BTW, if you have created a new user via "createUserWizard" , the
user may be set to online status. You may need to logout first(also it may
take some time to make it take effect due to the delay used for the
membership to calculate the expire).

for your scenario, do you mean if you click such button multiple times, it
will return different results?

Sincerely,

Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
>>From: "Nick" <a@a.com>
References: <#Q**************@TK2MSFTNGP05.phx.gbl>
<j2**************@TK2MSFTNGHUB02.phx.gbl>
<#Q**************@TK2MSFTNGP06.phx.gbl>
<$8**************@TK2MSFTNGHUB02.phx.gbl>
>>Subject: Re: What's the deal with Membership.GetNumberOfUsersOnline?
Date: Fri, 8 Aug 2008 13:43:10 +0100
>>
Hi Steven

No it won't you, have completely misunderstood. I wrote that method
as
>>an alternative to GetNumberOfUsersOnline, neither of which produce
consistent results.

In fact, that code sample doesn't even have a call to
GetNumberOfUsersOnline in it.

Nick.

"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:$8******************@TK2MSFTNGHUB02.phx.gbl ...
>>Hi Nick,

Per the document, the method call on "MembershipUser.IsOnline" may
update
its online status. Therefore, I suggest you try calling
"Membership.GetNumberOfuserOnline" several times without accessing each
user's IsOnline property(remove the foreach loop). I think it will make
the
"Membership.GetNumberOfuserOnline" call return the consistent result.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Aug 21 '08 #8

P: n/a
You're welcome Nick.

Glad that you've figured it out!

Sincerely,

Steven Cheng
Microsoft MSDN Online Support Lead

--------------------
>From: "Nick" <a@a.com>
Subject: Re: What's the deal with Membership.GetNumberOfUsersOnline?
Date: Thu, 21 Aug 2008 10:54:48 +0100
>Hi Steven,

I have found the problem, further down in the code there is an offending
GetUser call, this has been fixed and now the problem is resolved. Thanks
a
>million for your time, it's been most appreciated.

Nick.

"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:ZI****************@TK2MSFTNGHUB02.phx.gbl. ..
>Thanks for your reply Nick,

I have performed some local tests(using the default SQLExpress membership
provider). Here is a test page I used two buttons to simulate two methods
to check Users online:
==============================
public partial class status : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
foreach (MembershipUser user in Membership.GetAllUsers())
{
Response.Write("<br/>" + user.UserName + ": " +
user.IsOnline);
> }
}
protected void Button2_Click(object sender, EventArgs e)
{
Label1.Text = "Users Online: " +
Membership.GetNumberOfUsersOnline().ToString();
}
}
======================

It seems the result will keep the same when I press the button multiple
times. BTW, if you have created a new user via "createUserWizard" , the
user may be set to online status. You may need to logout first(also it
may
>take some time to make it take effect due to the delay used for the
membership to calculate the expire).

for your scenario, do you mean if you click such button multiple times,
it
>will return different results?

Sincerely,

Steven Cheng
Microsoft MSDN Online Support Lead
Aug 22 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.