Get MAC Address from the application's client machine


I would like to know the best way to get the client MAC Address from my Asp.Net Web Forms application. Since it's low-level information, I do not think it's as simple as it sounds.

asked by anonymous 18.02.2014 / 20:16

3 answers


It is not possible to get this information, since neither has access to this client machine information nor Javascript, as it is not trafficked as part of the Http protocol.

The only way to get this information would be through an ActiveX component or Java applet that would need to be installed on the client machine and the appropriate security settings applied.

18.02.2014 / 21:05

If your clients are on the same LAN as you (for example, on an intranet), your MAC addresses may be present in the router's ARP table.

In a Windows environment, you can check the ARP table via ARP -a command:



        pProcess.StartInfo.Arguments = "-a " + ipAddress;
        pProcess.StartInfo.UseShellExecute = false;
        pProcess.StartInfo.RedirectStandardOutput = true;
          pProcess.StartInfo.CreateNoWindow = true;
        string strOutput = pProcess.StandardOutput.ReadToEnd();
        string[] substrings = strOutput.Split('-');
        if (substrings.Length >= 8)
           macAddress = substrings[3].Substring(Math.Max(0, substrings[3].Length - 2)) + "-" + substrings[4] + "-" + substrings[5] + "-" + substrings[6] + "-" + substrings[7] + "-" +
                  substrings[8].Substring(0, 2);
            return macAddress;

            return "not found";
19.02.2014 / 20:19

Friends, by mistake I did not realize that it was a WEB application.

Follow the javascript solution to list the MAC addresses, however it uses an ActiveX and will only work in IE. I'll look for you if there are any multi-browser solutions.

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Getting MAC Address From Javascript(IE Only)</title>

    <script language="javascript">
    function showMacAddress(){

        var obj = new ActiveXObject("WbemScripting.SWbemLocator");
        var s = obj.ConnectServer(".");
        var properties = s.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
        var e = new Enumerator (properties);

        var output;
        output='<table border="0" cellPadding="5px" cellSpacing="1px" bgColor="#CCCCCC">';
        output=output + '<tr bgColor="#EAEAEA"><td>Caption</td><td>MACAddress</td></tr>';

            var p = e.item ();
            if(!p) continue;
            output=output + '<tr bgColor="#FFFFFF">';
            output=output + '<td>' + p.Caption; + '</td>';
            output=output + '<td>' + p.MACAddress + '</td>';
            output=output + '</tr>';

        output=output + '</table>';

        <input type="button" value="Show MAC Address" onclick="showMacAddress()" />

        <div id="box">
06.03.2014 / 23:38