如何从C#ASP.Net Web应用程序获取客户端系统MAC地址

问题描述:

如何从C#ASP.Net Web应用程序获取客户端系统MAC地址

How to get client system MAC Address from C# ASP.Net web application

尝试以下内容:



Try below:

You need to import the System.Net namespace for this to work. This will support IPv4 and IPv6.

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





如果 使用c#在消息框中获取MAC地址[ ^ ]



Also check the link if get MAC address in message box using c#[^]