Click here to Skip to main content
15,878,809 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
private string GetMACAddress() //----------------------retrive client MAC address
{
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
String sMacAddress = string.Empty;
foreach (NetworkInterface adapter in nics)
{

if (adapter.OperationalStatus==OperationalStatus.Up)
{
sMacAddress = adapter.GetPhysicalAddress().ToString();
break;
}
}
return sMacAddress;
}
Posted
Comments
Krunal Rohit 22-Nov-15 11:19am    
Umm, no you can't.
Done.

-KR

1 solution

You can NOT get the client MAC address in an ASP.NET application.

The code you posted is getting the interfaces on the SERVER, not the client. ASP.NET code always runs entirely on the server, never the client.

Also, the MAC address is meaningless outside of the network the client is sitting on. It is NOT a globally unique value and cannot be used to identify a client uniquely.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 25-Apr-16 0:18am    
5ed.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900