Q:

Get machine's mac address c#

I'm working on an ASP.NET MVC application and I want to get user's MAC address. After some research, I found this code: 
string GetMacAddress()
{
    string macAddresses = "";
    foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
    {
        if (nic.NetworkInterfaceType != NetworkInterfaceType.Ethernet)
            continue;
        if (nic.OperationalStatus == OperationalStatus.Up)
        {
            macAddresses += nic.GetPhysicalAddress().ToString();
            break;
        }
    }

    return macAddresses;
}

There are no errors but I always get an empty address. Does anyone know how to solve this?

A:

I'm workin on an mvc .net application and I want to get user's mac address.

You can forget about it, that's not possible. You can get only the IP address of the client that is browsing your website.
Actually there is one way to get it. Add the following in your view:
@using (Html.BeginForm())
{
    @Html.Label("Mac", "Please enter your MAC address")
    @Html.TextBox("Mac")
    <button type="submit">OK</button>
}

and inside the corresponding controller action:
[HttpPost]
public ActionResult SomeAction(string mac)
{
    // if the user was kind enough to provide you his MAC address
    // you could read it from the mac argument
    // Of course he could have entered any MAC address he likes and
    // you have no way of verifying that
    ...
}

Yet another possibility is to develop an ActiveX control (that will work only under IE) and that the user can install in his browser which could retrieve the MAC address of his NIC and send it to the server.

