Get client IP address from server

    public static IPAddress GetIpAddress(HttpRequestBase request)
    {
        string[] headers = new string[]{
            "CLIENT-IP",
            "X-FORWARDED",
            "X-CLUSTER-CLIENT-IP",
            "FORWARDED-FOR",
            "FORWARDED"
        }
        IPAddress pAddress = null;

        if (request.Headers["X-FORWARDED-FOR"] != null)
        {
            string item = request.Headers["X-FORWARDED-FOR"];
            if (IPAddress.TryParse(item.Split(new char[] { ',' })[0].Trim(), out pAddress))
                return pAddress;
        }
        else
        {
            foreach (var h in headers)
                if (IPAddress.TryParse(request.Headers[h], out pAddress))
                    return pAddress;
        }

        IPAddress.TryParse(request.UserHostAddress, out pAddress);
        return pAddress;
    }