Get IPv4 addresses from Dns.GetHostEntry()

前端 未结 7 1512
长发绾君心
长发绾君心 2020-11-27 04:49

I\'ve got some code here that works great on IPv4 machines, but on our build server (an IPv6) it fails. In a nutshell:

IPHostEntry ipHostEntry = Dns.GetHost         


        
7条回答
  •  渐次进展
    2020-11-27 05:31

    IPv6

    lblIP.Text = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName).AddressList(0).ToString()


    IPv4

    lblIP.Text = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName).AddressList(1).ToString()

提交回复
热议问题