确定ASP.NET站点的“活跃”用户数 [英] Determining an 'active' user count of an ASP.NET site

查看:159
本文介绍了确定ASP.NET站点的“活跃”用户数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个ASP.NET网站,什么是可以用来跟踪有多少用户在该网站在任何特定的时间点记录的一些技巧?

On an ASP.NET site, what are some techniques that could be used to track how many users are logged in to the site at any given point in time?

因此​​,例如,我可能会产生一个报告,显示是这样的:

So for example, I could produce a report showing something like this:

        10:00am  11:00am  12:00pm  1:00pm  2:00pm ....
 3/25      25      32       45      40      37
 3/26      31      38       50      57      40
 3/27      28      37       46      35      20
 etc.

编辑:没有,我们没有使用ASP.NET成员资格提供程序,它使用一个土生土长/哈克基于会话确定用户是否在登录状态的方法

No, we're not using ASP.NET Membership provider, it uses a home-grown/hacky session based method of determining whether or not a user is in 'logged in' status.

推荐答案

该网站是否登录的用户?如果确实如此,那么你可以每次申请一个新的页面,然后每隔一小时时间更新在用户表中的最后访问现场,只是做,抓住大家谁都有内的最后一个最近访问时间戳的SQL查询15分钟左右(假设为目前在网站上)。

Does the website log the user in? If it does, then you can update a "Last Visit" field in the user table every time they request a new page, and then every hour, just do a SQL query that grabs everybody who has a "Last Visit" timestamp within the last 15 minutes or so (assumed to currently be on the site).

如果你没有让人们登录,您可以很容易地通过IP地址而不是用户名做。使用这种方法,不过,你可能会碰到一些代理问题(即由同一个企业网络中的多个用户可能都来自同一个IP地址,所以他们只算在你的总量一个用户),但应该是最小的。

If you're not having people log in, you could just as easily do it by IP address instead of username. With this method, though, you may run into some proxy issues (ie multiple users from the same corporate network may all come from a single IP address, so they only count as one user in your totals), but that should be minimal.

这篇关于确定ASP.NET站点的“活跃”用户数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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