本文介绍了如何获得客户端的MACID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

我想获取客户端MACID.但是当使用下面的代码时,我得到了服务器端的MACID.

protected void Page_Load(object sender, EventArgs e)
   {
       ManagementObjectSearcher objQuery = null;
       ManagementObjectCollection queryCollection = null;

       try
       {
           objQuery = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration");

           queryCollection = objQuery.Get();

           foreach (ManagementObject mgmtObject in queryCollection)
           {
               if (mgmtObject["MacAddress"] != null)
               {
                   Response.Write(mgmtObject["MacAddress"].ToString());
               }
           }
       }
       catch (Exception ex)
       {
           Response.Write(ex.Source);
           Response.Write(ex.Message);
       }
   }





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();
                Response.Write(sMacAddress);
            }
        }



请给我样本代码.

问候,
Mahalakshmi S

解决方案


这篇关于如何获得客户端的MACID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 05:11