简体   繁体   English

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

[英]How can I find number of visitors/users at my site (IIS7/asp.net) at any given moment?

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. 该站点在iis7上运行,我们正在使用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. 不需要历史记录,我只想知道现在有多少用户“在线”,并将其显示在页面本身上。

You can use Windows Performance counters for this (perfmon) 您可以为此使用Windows Performance计数器(性能)

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

You can access these performance counters using the System.Diagnostics namespace. 您可以使用System.Diagnostics命名空间访问这些性能计数器。

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 我遇到了这个问题,因此如果计数器似乎过高,请看这里: http : //support.microsoft.com/kb/969722

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. 例如,会话通常持续预定义的持续时间,例如30分钟。 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. 通常,您希望最近n分钟内一直在线的人。 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. 会话会在一段时间内为您提供此统计信息(配置的会话到期),但是还有许多其他时间度量可能更相关。

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. 实现此目的的一种方法是简单地使IIS日志将其数据推入数据库中的表中,而不是将其推到本地文件系统中。 This is pretty easy to configure at the web server level. 这在Web服务器级别很容易配置。

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. 当然,如果您的网站流量很高,那么这将导致收集大量数据。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何确定ASP.NET站点(IIS)上的用户数? 他们的信息? - How can I determine the number of users on an ASP.NET site (IIS)? And their info? 如何在IIS7中设置本地ASP.NET 2.0站点以进行本地测试? - How do I set up a local ASP.NET 2.0 site in IIS7 for local testing? 如何使用Vista和IIS7通过ASP.Net复制文件? - How can I copy files with ASP.Net using Vista and IIS7? 在哪里可以学习如何将ASP.NET 4 MVC 2应用程序部署到IIS7? - Where can I learn how to deploy ASP.NET 4 MVC 2 applications to IIS7? 如何在ASP.NET缓存应用程序中超过IIS7的60%内存限制 - How can I exceed the 60% Memory Limit of IIS7 in ASP.NET Caching application 如何在IIS7 Web服务器上运行的ASP.NET应用程序中使用集成安全性? - How I can use Integrated Security in a ASP.NET Application that runs on a IIS7 Webserver? 对于iis7应用程序asp.net 2.0的ConCurrent Users限制 - ConCurrent Users Limit for iis7 application asp.net 2.0 “字典中不存在给定的键” IIS7 上的 ASP.NET 错误 - “The given key was not present in the dictionary” ASP.NET error on IIS7 如何在asp.net IIS7中隐藏任何页面扩展名(如.aspx和.asp和.php和.html) - How to Hide any page extension like (.aspx and .asp and .php and .html) in asp.net IIS7 我可以通过我的 ASP.NET 应用程序以编程方式将 IP 地址添加到 IIS7 中的动态 IP 限制扩展吗? - Can I programmatically add an IP address to Dynamic IP Restrictions extension in IIS7 from my ASP.NET app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM