My below code is getting ivp6 ip address am not sure how to get ipv4 in the same manner.
string ipAddress = "";
if (Dns.GetHostAddresses(Dns.GetHostName()).Length > 0)
{
ipAddress = Dns.GetHostAddresses(Dns.GetHostName())[0].ToString();
}
Dns.GetHostName()has nothing to do with the client.string strHostName = System.Net.Dns.GetHostName(); IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(strHostName); IPAddress[] addr = ipEntry.AddressList;In IPAddress array you can will get both the IP'S IPV4 and IPV6