获取客户端、服务器、本地IP地址

//获取客户端、服务器、本地IP地址
        public static string getIPAddress()
        {
            ////本地IP
            //string address = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName()).GetValue(2).ToString();//IP4 地址
            ////本地电脑名称
            //string addname = System.Net.Dns.GetHostName().ToString(); 

            //客户端IP
            HttpRequest Request = HttpContext.Current.Request;
            string clientIP = Request.UserHostAddress;

            return clientIP;
        }

  

原文地址:https://www.cnblogs.com/lengv10/p/3807740.html