asp.net 获取客户机的网卡MAC地址
第一步
[开始]--[运行]--wmimgmt.msc--右击[WMI控件]--选择属性--选择安全--选择节点下的cimv2--单击安全设置--添加aspnet用户--启用远程控制
第二步
修改machine.config文件中的<processModel>的"username"的值为"system"
重新启动iis
第三步
在vs中手动在解决方案中引用上添加"System.Management"命名空间
第四步
加入代码
1using System.Management;
2
3ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
4 ManagementObjectCollection moc = mc.GetInstances();
5 foreach(ManagementObject mo in moc)
6 {
7 if((bool)mo["IPEnabled"] == true)
8 Response.Write("网卡的序列号为:"+ mo["MacAddress"].ToString());
9 }
10
11
12ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
13disk.Get();
14
15Response.Write("主板的序列号为: " + disk.GetPropertyValue("VolumeSerialNumber").ToString());
16
2
3ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
4 ManagementObjectCollection moc = mc.GetInstances();
5 foreach(ManagementObject mo in moc)
6 {
7 if((bool)mo["IPEnabled"] == true)
8 Response.Write("网卡的序列号为:"+ mo["MacAddress"].ToString());
9 }
10
11
12ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
13disk.Get();
14
15Response.Write("主板的序列号为: " + disk.GetPropertyValue("VolumeSerialNumber").ToString());
16