Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get mac address of client that browse web site by asp.net mvc c#

I'm trying to get mac address from the client's machine that browse my web site, I've been used this:

using System.Management;
class Sample_ManagementClass
{
    public static int Main(string[] args)
    {
        ManagementClass objMC = new
        ManagementClass("Win32_NetworkAdapterConfiguration");
        ManagementObjectCollection objMOC = objMC.GetInstances();

        foreach (ManagementObject objMO in objMOC)
        {
            if (!(bool)objMO["ipEnabled"])
                continue;

            Console.WriteLine((string)objMO["MACAddress"]);
        }
    }
 }

But it is not recognized Management Namespace, so what should I do?

like image 668
titi Avatar asked Jan 06 '12 10:01

titi


People also ask

How do I find the MAC address of a client Web?

To get the MAC address, pass the parameter 'getmac' which returns the MAC address of the client. 'getmac' is a CMD command to get the MAC address.

Can I get MAC address from http request?

MAC is a property of a TCP packet, and on HTTP level there're no packets or MACs (for example, a single HTTP request might be assembled of several TCP packets). You could try using a packet sniffer (like WireShark) to capture TCP packets, and then analyze them to extract MACs and map them to HTTP requests.

How do I find the source of a MAC address?

Android: In most cases, you can follow this procedure to locate your MAC address: Select Settings > About Device > Status. A WiFi Address or WiFi MAC Address displays.


1 Answers

it's unfortunately not possible to reliably get the mac address of the client machine due to firewalls, proxies and ISP generic addresses being given. However, you can make a stab at getting the ip address by using:

var remoteIpAddress = Request.UserHostAddress;

However, this may or may not actually represent the client machine and is more likely the ISP gateway or some other ip address. It's a well known problem and one that even google have found hard to crack using clientside javascript (the idea here being that you get the actual local ip address via a js library and pass that over to your server function).

[edit] - might be worth taking a look at the following for inspiration/confirmation of the issue:

http://www.dotnetfunda.com/forums/thread2088-how-to-get-mac-address-of-client-machine.aspx

like image 53
jim tollan Avatar answered Sep 28 '22 02:09

jim tollan