ASP.NET看看会员在线 [英] ASP.NET see if member is online

查看:207
本文介绍了ASP.NET看看会员在线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发一个一把umbraco ASP.NET网站,我要看看是否给定ID的成员是否在线。我该怎么做?

I'm developing a ASP.NET site in umbraco, and I need to see if a member with a given ID is online. How can I do that?

到目前为止,我已经试过这么让成员:

So far, I've tried to get the member by so:

Member m = new Member(myID);

但我怎么可以检查,如果返回的成员登录与否?

But how can I check, if the returned member is logged in or not?

编辑:我跟着链接,并从中提取出以下code:

I followed the link, and extracted the following code from it:

var users = Membership.GetAllUsers();

foreach(MembershipUser user in users){
  Response.Write(user.IsOnline.ToString() +"<br/>");
  Response.Write(user.LastActivityDate.ToString() + "<br/>");
  Response.Write(user.LastLoginDate.ToString() + "<br/>");
}

但是,返回的结果表明,财产isOnline是如此的每一个成员,即使他们不在线。我知道,这是因为这一事实,即自动更新LastActivityDate每当我访问用户,如下所述:<一href=\"http://stackoverflow.com/questions/3438200/is-it-possible-to-access-a-profile-without-updating-lastactivitydate\">Is它可以访问一个配置文件,而无需更新LastActivityDate?。不幸的是,我没有得到解决了这个问题。

However, the returned result shows that the property isOnline is true for every member, even though they're not online. I'm aware that it is because of the fact that the LastActivityDate updates automatically whenever I access the user, as stated here: Is it possible to access a profile without updating LastActivityDate?. Unfortunately, I don't get the solution to that question.

我也试图通过访问该成员:
    的MembershipUser M = Membership.GetUser('身份识别码,假);
但是,即使我把false作为第二个参数,该LastActivityDate仍然更新。我该如何解决此问题?我要指出,我与ASP.NET v工作。4.0一把umbraco 4.7在本地主机。

I've also tried to access the member by: MembershipUser m = Membership.GetUser('myID',false); But even though I put false as the second parameter, the LastActivityDate still updates. How can I work around this? I should note that I work with ASP.NET v. 4.0 in umbraco 4.7 at a localhost.

谢谢!

:编辑结束

最好的问候,
Brinck10

Best regards, Brinck10

推荐答案

您可以使用的 MembershipUser.IsOnline物业这个节目真,如果当前日期和时间减去UserIsOnlineTimeWindow属性值是早于lastActivityDate的用户。

You can use the MembershipUser.IsOnline Property that show true if the current date and time minus the UserIsOnlineTimeWindow property value is earlier than the lastActivityDate for the user.

有是在 MSDN页面为例

相关:结果
<一href=\"http://stackoverflow.com/questions/1130548/proper-100-isonline-implementation-for-asp-net-membership\">Proper 100%IsOnline实施asp.net会员结果
如果用户如何在ASP.NET检查在线?结果
<一href=\"http://stackoverflow.com/questions/1288248/asp-net-custom-membership-provider-isonline-property\">asp.net定义成员资格提供:IsOnline财产

这篇关于ASP.NET看看会员在线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆