I try to get my local ip, the code below shows you how I do that.
The problem with this is when I'm connected to wifi and my ethernet-card is not connected it gives me a 169.xxx.xxx.xxx address.
How can I make a check to see which network card is connected, and get that ip?
private string GetLocalIP()
{
IPHostEntry host;
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
return ip.ToString();
}
return "127.0.0.1";
}