确定 ASP.NET 站点的“活动"用户数

时间:2023-04-01
本文介绍了确定 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 成员资格提供程序,它使用基于本地/hacky 会话的方法来确定用户是否处于登录"状态.

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 站点的“活动"用户数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:从 C# 中的加权列表中选择 x 个随机元素(无需替换 下一篇:是否有执行 Excel NORMINV 函数的 C# 库?

相关文章

最新文章