Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
hi how to get client mac address?
C#
string macAddresses = "";

        foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
        {
            if (nic.OperationalStatus == OperationalStatus.Up)
            {
                macAddresses += nic.GetPhysicalAddress().ToString();
                break;
            }
        }


it is my code. but this code return server mac address

please help me!
Posted

The short answer is: No

It is not possible to get the MAC address from the client using JavaScript as this will pose a serious security risk.

The only unique id you will be able to get is the IP address, but this will possibly not be unique as the user's machine might be NATed behind a router.

You could use an ActiveX control on Java applet to get the client machine's MAC address, but this would require installation of the chosen method on the client machine and will never be a fail-safe way of obtaining the MAC address.
 
Share this answer
 
Comments
[no name] 5-Apr-14 8:29am    
please check this key word

how to get client mac address in asp.net c#

?How can?
Sergey Alexandrovich Kryukov 5-Apr-14 22:19pm    
5ed.
—SA
You can't. Its that simple.

The code you have will only give you the MAC addresses of the server not the clients. There is no reliable way to get the MAC of clients in a web app because of how networking works. The best you're going to get is the MAC address of the interface on the router closest to the web server.

The only way it works is if the clients are on the same physical subnet as the web server and you have to use ARP resolution to get it. But, like I said, it only works if the clients are on the same physical subnet as your server.
 
Share this answer
 
Comments
[no name] 5-Apr-14 8:29am    
please check this key word

how to get client mac address in asp.net c#

?How can?
Dave Kreskowiak 5-Apr-14 8:34am    
YOU CAN'T. If you understood how Ethernet networking works you would know this.
Sergey Alexandrovich Kryukov 5-Apr-14 22:21pm    
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