获取服务器mac地址,但我想要客户端mac地址

编程入门 行业动态 更新时间:2024-10-25 20:31:00
本文介绍了获取服务器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地址

本文发布于:2023-08-07 03:36:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1316750.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:地址   但我   客户端   服务器   mac

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!