Many network adapters at machine, need to find one that is used for traffic in Windows (from .net)
- by viko
My application use Web-service. I'm control from what workstation was request and for this send MAC-Address how parameter of all methods. But then I start testing application in real, I found workstations which have many network adapters - Ethernet, Wireless, Bluetooth. When I get MAC-address using next code:
var networkAdapters = NetworkInterface.GetAllNetworkInterfaces();
if (networkAdapters == null || networkAdapters.Length == 0)
return string.Empty;
string address = string.Empty;
foreach (var adapter in networkAdapters)
{
var a = adapter.GetPhysicalAddress();
if (a != null && a.ToString() != string.Empty)
{
address = a.ToString();
break;
}
}
return address;
Sometimes Web-service receive from workstation different MAC-Addresses, but I want get always only one MAC-address. Please, help me.