string userIp = Request.UserHostAddress.ToString(); 
        string ipa=Request .ServerVariables ["REMOTE_ADDR"]; 
        this.Label1.Text = userIp+"a"+ipa; 
        //主机ip 
        string hostip = Dns.GetHostName(); 
        IPAddress[] ips; 
        ips = Dns.GetHostAddresses(hostip); 
        foreach (IPAddress ip in ips) 
        { 
            this.TextBox1.Text = ip.ToString (); 
        }   

解决方案 »

  1.   

     string userIp = Request.UserHostAddress.ToString(); 
            string ipa=Request .ServerVariables ["REMOTE_ADDR"]; 
            this.Label1.Text = userIp+"a"+ipa; 
            //主机ip 
            string hostip = Dns.GetHostName(); 
            IPAddress[] ips; 
            ips = Dns.GetHostAddresses(hostip); 
            foreach (IPAddress ip in ips) 
            { 
                this.TextBox1.Text = ip.ToString (); 
            }   
      

  2.   

     string userIp = Request.UserHostAddress.ToString(); 
            string ipa=Request .ServerVariables ["REMOTE_ADDR"]; 
            this.Label1.Text = userIp+"a"+ipa; 
            //主机ip 
            string hostip = Dns.GetHostName(); 
            IPAddress[] ips; 
            ips = Dns.GetHostAddresses(hostip); 
            foreach (IPAddress ip in ips) 
            { 
                this.TextBox1.Text = ip.ToString (); 
            }   
      

  3.   

    你做一个测试不久清楚了??!!
    将Local_Addr换做你的主机名。
      

  4.   

    protected   string   GetIP()   //获取本地IP 

      IPHostEntry   ipHost   =   Dns.Resolve(Dns.GetHostName()); 
      IPAddress   ipAddr   =   ipHost.AddressList[0]; 
      return   ipAddr.ToString(); 
    }
      

  5.   

    Request.ServerVariables.Get("Local_Addr").ToString();
    获取服务器IP