确定 ASP.NET 站点的“活动"用户数
- 作者: 喵喵喵3_
- 来源: 51数据库
- 2023-02-08
问题描述
在 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.
- C#通过fleck实现wss协议的WebSocket多人Web实时聊天(附源码)
- 团队城市未满足要求:MSBuildTools12.0_x86_Path 存在
- 使用 MSBuild.exe 在发布模式下构建 C# 解决方案
- 当我发布 Web 应用程序时,AfterPublish 脚本不运行
- 构建时 T4 转换的产品仅在下一个构建中使用
- ASP.NET Core Application (.NET Framework) for Windows x64 only error in project.assets.json
- 新的 .csproj 格式 - 如何将整个目录指定为“链接文件"到子目录?
- 如何将条件编译符号(DefineConstants)传递给 msbuild
- MSBuild 支持 Visual Studio 2017 RTM 中的 T4 模板
- NuGet 包还原找不到包,没有源
