简体   繁体   English

下次算不上 客户端连接到服务器

[英].Next count no. clients connected to the server

i have used the ASP.NET with C# . 我已经将ASP.NET与C#一起使用了。 i want to check how many client send request to the web server . 我想检查有多少客户端向Web服务器发送请求。 i have deploy the web page in IIS server then when i have accessed this site from the another computer using IP address of the IIS web server . 我已经将网页部署在IIS服务器中,然后当我使用IIS Web服务器的IP地址从另一台计算机访问此站点时。

How to count no. 如何计算不。 clients connected to the server? 客户端连接到服务器?

use the below function to get the IP and log this. 使用以下功能获取IP并将其记录下来。 Then take the unique IP to find out how many computers connect to your server 然后使用唯一的IP找出连接到服务器的计算机数量

public static string GetIPAddress()
{
    System.Web.HttpContext context = System.Web.HttpContext.Current;
    string sIPAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
    if (string.IsNullOrEmpty(sIPAddress)) {
        return context.Request.ServerVariables["REMOTE_ADDR"];
    } else {
        string[] ipArray = sIPAddress.Split(new Char[] { ',' });
        return ipArray[0];
    }
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM