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);
}
不知是我用错了,还是其它的什么问题!望大家帮帮我!
下面的这种只能取到服务器端的!
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);
}
不知是我用错了,还是其它的什么问题!望大家帮帮我!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货