我获取客户端地址  在本地测试是好錒 但服务器上却获取到自己服务器地址了
是什么原因錒,大家帮我看下···
  我获取IP的2种方法:
  1.      public static string GetIPAddress()
        {            string user_IP = string.Empty;
            if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
            {
                if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null)
                {
                    user_IP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
                }
                else
                {
                    user_IP = System.Web.HttpContext.Current.Request.UserHostAddress;
                }
            }
            else
            {
                user_IP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
            }
            return user_IP;
        }
2.info.IP = this.Page.Request.UserHostAddress.ToString();

解决方案 »

  1.   

    ISA防火墙设置问题?
    http://www.cnblogs.com/cnaspnet/archive/2008/07/05/1236181.html
      

  2.   

    public static string GetClientIP(HttpRequest request)
            {
                string ipAddress;
                string http_x_forwarded_for = request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                if (http_x_forwarded_for == null || http_x_forwarded_for == "" || http_x_forwarded_for.IndexOf("unknown") > 0)
                {
                    ipAddress = request.ServerVariables["REMOTE_ADDR"];
                }
                else if (http_x_forwarded_for.IndexOf(",") > 0)
                {
                    ipAddress = http_x_forwarded_for.Substring(0, http_x_forwarded_for.IndexOf(",") - 1);
                }
                else if (http_x_forwarded_for.IndexOf(";") > 0)
                {
                    ipAddress = http_x_forwarded_for.Substring(0, http_x_forwarded_for.IndexOf(";") - 1);
                }
                else
                {
                    ipAddress = http_x_forwarded_for;
                }
                return ipAddress;//.Substring(1,30);
            }
      

  3.   

    http://topic.csdn.net/u/20090617/11/8f0432b6-84ee-49da-a55f-86b3d343ab8b.html?85747
      

  4.   

    网上有个免费的获取客户端ip地址的webservice,你用它就OK了。