asp.net如何获取客户端网卡mac地址?
asp.net如何获取客户端网卡mac地址?
下面的这种只能取到服务器端的!
ManagementClass mc = new ManagementClass( "Win32_NetworkAdapterConfiguration ");
ManagementObjectCollection moc2 = mc.GetInstances();
foreach (ManagementObject mo in moc2)
{
if ((bool)mo[ "IPEnabled "] == true)
v_localUnique = mo[ "MacAddress "].ToString();
mo.Dispose();
}
下面这种也不行
string mac= " ";
Process process=new Process();
process.StartInfo.FileName= "nbtstat ";
string ip = Request.UserHostAddress.ToString();
process.StartInfo.Arguments = "-a " + ip;
process.StartInfo.UseShellExecute=false;
process.StartInfo.CreateNoWindow=true;
process.StartInfo.RedirectStandardOutput=true;
process.Start();
string output=process.StandardOutput.ReadToEnd();
int length=output.IndexOf( "MAC Address = ");
if(length> 0)
{
mac=output.Substring(length+14,17);
}
不知是我用错了,还是其它的什么问题!望大家教教我!
------解决方案--------------------//添加组件System.Management
using System.Management;
using System.Runtime.InteropServices;
<