Click here to Skip to main content
15,887,421 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i'm getting visitor's physical address from server using following code
C#
public string GetMACAddress()
        {
            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;
        }

unfortunately this was prevented by hosting system administrator.
what need to be done to make allow it through web configuration file.
Posted
Comments
Kornfeld Eliyahu Peter 6-Dec-15 7:53am    
Not clear the context of your code! What application? What hosting?
In any case. Did you asked the host?
Leo Rajendra Dhakal 6-Dec-15 8:13am    
yes. according to him we can't change the security policy due to need of secured system. but i need the each visitors system mac address by which if not a genius visitor forward to another web address after checking it.
Kornfeld Eliyahu Peter 6-Dec-15 8:17am    
So you have to look for an other host to allow you access to such info...If you were able to brake security policies set up by host administrator it would be very bad...
Richard MacCutchan 6-Dec-15 8:27am    
There is nothing to do. Security restrictions are set for a reason, usually to keep hackers out.

1 solution

Um. You do realize that even with what Peter and Richard have said, you can't get the MAC address of a visitor to your website, and that code will only return MAC addresses for computers on the local segment, even if the "hosting system administrator" would permit it.

MAC addresses do not go past the router which connects the kit to the internet (and wouldn't work if they did since they only have to be unique within a LAN segment and are not unique globally). It's also incredibly easy to "spoof" MAC addresses.

And to add to that, the MAC address doesn't give you an information about a physical location: it's a small code which identifies a network component until it can be assigned an IP address. And the IP address won;t give you any reliable info about geographical location either.

Use cookies to identify authorised users instead. No cookie, no entry.
 
Share this answer
 

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