获取客户端IP

   string clientIP = HttpContext.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                    if (string.IsNullOrEmpty(clientIP))
                        clientIP = HttpContext.Request.ServerVariables["REMOTE_ADDR"];
                    if (string.IsNullOrEmpty(clientIP))
                        clientIP = HttpContext.Request.UserHostAddress;

原文地址:https://www.cnblogs.com/cjmtt/p/2714982.html