Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have published my application in azure server. Its like a one computer. I have tried to get the visitors system mac address through my website browser but i couldn't get it perfectly. Azure server system mac address only get from my code. Tried lot of coding which was suggested by the code project

Some one please help to resolve my issues immediately.

What I have tried:

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;
    }
Posted
Updated 5-Dec-19 18:25pm
Comments
F-ES Sitecore 5-Dec-19 7:57am    
Please do basic research like googling before asking a question. This is a very frequently asked question.

You simply can't do that. MAC address is not sent during the request.

You only can get MAC address of the machine which is executing your code.
 
Share this answer
 
Comments
vijisks 6-Dec-19 0:27am    
Thanks for your immediate response.

We want to monitor the login activities of visitors details for security purpose. So we need to capture the Static IP address.

If is it possible to get visitor system IP address?
MAC addresses aren't usable, partly because they don't go past the router or switch to which the device is connected (they are used to uniquely identify a device on a LAN segment so that it can be assigned a local IP address which is used by all future communications between the router and the device) and partly because they aren't unique - they are only unique within a LAN segment.

Even if you could get it - which you can't - it wouldn't do you any good as a way of "uniquely identifying a device" because they can be spoofed so easily: every VMN has its own MAC address for example which is different to the MAC address of the device hosting the VM.
 
Share this answer
 
Comments
vijisks 6-Dec-19 0:27am    
Thanks for your immediate response.

We want to monitor the login activities of visitors details for security purpose. So we need to capture the Static IP address.

If is it possible to get visitor system IP address?
OriginalGriff 6-Dec-19 2:24am    
You need to learn a whole load more about how things work before you embark on this: the visitor IP address is no use to you either, for two reasons:
1) Most IP addresses aren't static - if you don't pay extra for it, you get a dynamic address. That means you can't rely on an IP to ID clients. There is some explanation here:

https://www.codeproject.com/Tips/792723/Using-IP-based-Geolocation-and-why-its-pretty-much

2) IP addresses aren't unique to a system: local IP addresses (between the Router and the client are, but aren't normally static either, but they don't transfer past the router and are all generally of the form 192.168.xxx.yyy which means that thousands of your users could have identical local IP addresses).
The IP address you can get for your client is the IP address of the router and is shared by all clients using that router - you cannot detect which system the request is coming from.

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