-1

I want to get the mac address of the client whose visit my site.

Can Any one help me ..

I am using the following code but it return server mac address:-

NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
String sMacAddress = string.Empty;
foreach (NetworkInterface adapter in nics)
{
     if (sMacAddress == String.Empty)// only return MAC Address from first card  
     {
         IPInterfaceProperties properties = adapter.GetIPProperties();
         sMacAddress = adapter.GetPhysicalAddress().ToString();
     }
}
return sMacAddress;

Thanks

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
  • you can get the ip address by using but not mac address. var remoteIpAddress = Request.UserHostAddress; [Check Here](http://www.dotnetfunda.com/forums/show/2088/how-to-get-mac-address-of-client-machine) – Manish Goswami Feb 16 '15 at 12:19
  • `GetAllNetworkInterfaces` returns information about the network interfaces in the local computer (probably your server in this case), not your visiting client. – haim770 Feb 16 '15 at 12:20
  • 2
    Are you after the physical address for a client within the same physical network, or for a remote internet client? – Rowland Shaw Feb 16 '15 at 12:20

2 Answers2

2

The mac address only works on the local network. NEVER gets out for the LAN.

If you need it, you must write some JavaScript code to get it.

If you need identify the user that go to visit your web page you can use a session ID, it is a cookie. A lot of web page use cookies.

Diego Juliao
  • 414
  • 6
  • 16
0

it's not possible to get the mac address of the client because it's on the ethernet physical layer, only the computers connected to the same TCP/IP local network can determine each other's MAC addresses. It is possible only when client and server in same LAN*, If they are on the same **LAN then using ARP(Address Resolution Protocol) We can find that

Arunprasanth K V
  • 20,733
  • 8
  • 41
  • 71