Expressio blend Shows ipv6 RRS feed

  • Question

  • Hello, i have the follow code in the event handler

    ipAddress = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString();
    ipAdd.Content = ipAddress;

    This gives me my local pc ip address , yes it shows my ipaddress in window XP

    However it gives me ipv6 ip address instead of ipv4 address

    How do i do it to get ipv4 address insead of ipv6 address? 

    Monday, February 21, 2011 9:35 AM

All replies

  • Hi!

    Have you tried looking here


    Try something like this

    Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault(a => AddressFamily.InterNetwork == a.AddressFamily) ?? he.AddressList[0];

    Tuesday, February 22, 2011 12:12 AM
  • I manage to solve the ipv4 by using this


    IPHostEntry ipE = Dns.GetHostByName(sHostName);

    IPAddress[] IpA = ipE.AddressList;

    for (int i = 0; i < IpA.Length; i++)


    ipadd.Content = IpA[i]




    However i have another problem which is to validating the textbox to the ipv4, i keep getting ipv6 ip from the validating string, the ipAddress keeps giving ipv6 address, how do i change it to ipv4(the ip works on window XP however window 7 has ipv6 and ipv4 ip, so it keeps taking ipv6) 

    if (string.Equals(ipbox, ipAddress))




    Tuesday, February 22, 2011 2:46 AM