如何在任何给定时刻找到我的网站 (IIS7/asp.net) 的访问者/用户数量?

发布于 2024-08-30 05:49:59 字数 139 浏览 2 评论 0原文

我需要显示有多少用户正在浏览我的网站。该网站运行在iis7上,我们使用的是asp.net 3.5。

活跃会话的数量是一个好的方法吗? 该数字不需要非常准确。

不需要历史记录,我只想知道现在有多少用户“在线”,并将其显示在页面本身上。

I need to display how many users are browsing my site. The site is running on iis7, and we are using asp.net 3.5.

Is the number of active sessions a good way to go?
The number does not need to be very accurate.

No history is needed, I just want to know how many users are "online" right now, and display that on the page itself.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

沫尐诺 2024-09-06 05:49:59

您可以使用 Windows 性能计数器来执行此 (perfmon)

ASP.NET 应用程序 >会话活动计数器。

您可以使用 System.Diagnostics 命名空间访问这些性能计数器。

这段代码对我有用:

        PerformanceCounter pc = new PerformanceCounter("ASP.NET Applications",
     "Sessions Active", "__Total__", "MYSERVERHOSTNAME.domain");

        while (true)
        {
            Console.WriteLine(pc.NextValue());
            System.Threading.Thread.Sleep(1000);
        }

我遇到了这个问题,所以如果计数器看起来太高,请看这里: http: //support.microsoft.com/kb/969722

You can use Windows Performance counters for this (perfmon)

ASP.NET Applications > Sessions Active counter.

You can access these performance counters using the System.Diagnostics namespace.

This code worked for me:

        PerformanceCounter pc = new PerformanceCounter("ASP.NET Applications",
     "Sessions Active", "__Total__", "MYSERVERHOSTNAME.domain");

        while (true)
        {
            Console.WriteLine(pc.NextValue());
            System.Threading.Thread.Sleep(1000);
        }

I had this problem so take a look here if the counter seems too high: http://support.microsoft.com/kb/969722

吾家有女初长成 2024-09-06 05:49:59

作为一般原则,您必须定义在线用户数量的含义。

例如,会话通常持续预定义的持续时间,例如 30 分钟。根据您期望用户在您的网站上停留的时间长短,会话的持续时间可能很大程度上归因于用户不在您的网站上时的空闲时间。

一般来说,您希望过去 n 分钟内一直在线的人。会话为您提供一段时间(配置的会话到期)的统计信息,但还有许多其他时间度量可能更相关。

As a general principle, you have to define what you mean by the number of users online.

For example, Sessions usually last for a predefined duration, such as 30 minutes. Depending on how long you expect users to be on your site, the duration of a session could be largely attributed to idle time when the user is not on your site.

In general you want people that have been online in the last n minutes. Sessions give you this statistic for one period of time (the configured session expiry), but there are many other time measures that would potentially be more relevant.

小忆控 2024-09-06 05:49:59

实现此目的的一种方法是简单地让 IIS 日志将其数据推送到数据库的表中,而不是本地文件系统中。这在 Web 服务器级别配置起来非常容易。

然后您可以轻松地绘制图表并显示全天、当前、每周等的使用情况。

当然,如果您有一个流量很高的网站,那么这将导致收集大量数据。

One way to accomplish this is to simply have the IIS logs shove their data in a table in your database instead of the local file system. This is pretty easy to configure at the web server level.

Then you could easily graph that and show usage throughout the day, current, weekly, etc.

Of course, if you have a highly trafficked site, then this would result in a tremendous amount of data collected.

月依秋水 2024-09-06 05:49:59

对于 EPiServer 网站,您可能需要查看实时监控:http: //www.episerver.com/add-on-store/episerver-live-monitor/

For EPiServer websites you may want to have a look at Live Monitor: http://www.episerver.com/add-on-store/episerver-live-monitor/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文