Mac地址c#MVC应用程序

时间:2017-10-10 04:41:48

标签: c# model-view-controller

如何获取用户访问网站的MAC地址。该网站使用MVC并托管在IIS上。

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;
}

我正在使用上面的代码,但这似乎不起作用。

0 个答案:

没有答案