获取服务器mac地址,但我想要客户端mac地址 [英] Getting server mac address but I want client mac address

查看:182
本文介绍了获取服务器mac地址,但我想要客户端mac地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

i试图获取客户端机器的mac地址,但是当我在服务器上传时,我得到服务器mac地址而不是客户端mac地址。

plz any这个问题的解决方案。

i想要客户端mac地址。



谢谢



我尝试过:



公共字符串GetMACAddress()

{

NetworkInterface [] nics = NetworkInterface.GetAllNetworkInterfaces();

String sMacAddress = string.Empty;

foreach(nics中的NetworkInterface适配器)

{

if(sMacAddress == String.Empty)//仅从第一张卡返回MAC地址

{

IPInterfaceProperties properties = adapter.GetIPProperties ();

sMacAddress = adapter.GetPhysicalAddress()。ToString();

}

}

返回sMacAddress;





}

Hello all,
i trying to get mac address of client machine but when i upload on server i am getting server mac address instead of client mac address.
plz any solution for this problem.
i want client mac address.

thanks

What I have tried:

public string GetMACAddress()
{
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();
}
}
return sMacAddress;


}

推荐答案

您无法在99.99%的情况下获取客户端MAC地址 - 基本上只有在客户端运行IE并启用了ActiveX时才能检索它 - 默认情况下不是这样。 MAC地址不会通过路由器传递到互联网,而是使用IP地址。

它似乎适用于您的开发机器,因为它们的clinet和服务器是同一台机器,所以当你返回MAC,你得到的服务器地址恰好与客户端相同。 C#代码始终在服务器上运行,因此它始终检索服务器信息。
You cannot get the Client MAC address in 99.99% of circumstances - basically you can only retrieve it if the client is running IE and has ActiveX enabled - which it isn't by default. The MAC address does not get passed through the router to the internet, an IP address is used instead.
It appeared to work on your development machine because they clinet and server were the same machine, so when you returned the MAC, you got the server address which happened to be the same as the Client. C# code always runs on the server, so it always retrieves server information.


这篇关于获取服务器mac地址,但我想要客户端mac地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆