获取客户端IP

获取客户端IP方法:

    private string GetClientIP()

    {

        string result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

        if (null == result || result == String.Empty)

        {

            result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

        }



        if (null == result || result == String.Empty)

        {

            result = HttpContext.Current.Request.UserHostAddress;

        }

        return result;

    }

你可能感兴趣的:(客户端)