Find System MAC Address using C#

protected void Page_Load(object sender, EventArgs e)
{
    Response.Write(GetMACAddress());
}

public string GetMACAddress()
{
        NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();        
        foreach (NetworkInterface adapter in nics)
        {
             if (sMacAddress == String.Empty)  // only return MAC Address from first card  
             {
                   IPInterfaceProperties properties = adapter.GetIPProperties();
                   return adapter.GetPhysicalAddress().ToString();
              }
        }
        return String.Empty;
}

Comments