获取客户端的MAC地址和IP地址访问我的网站

时间:2014-05-04 13:31:54

标签: c# asp.net

我使用的是ASP.NET网页,并希望获得一个的IP和MAC地址  客户访问我的网站。 有可能吗?

2 个答案:

答案 0 :(得分:0)

您可以从Request.UserHostAddress获取IP地址。

您无法获取MAC地址。

答案 1 :(得分:0)

您可以使用Request.UserHostAddress或Request.ServerVariables [“REMOTE_ADDR”]获取IP地址。如果客户端在代理服务器后面,那么您可以尝试使用ServerVariables [“HTTP_X_FORWARDED_FOR”]获取其IP。阅读here了解更多详情。

除非您的客户端与服务器位于同一物理子网上,否则无法获取MAC地址。在Intranet中获取MAC地址

//get all nics
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
//display the physical address of the first nic in the array,
//which should correspond to our mac address
Label1.Text = nics[0].GetPhysicalAddress().ToString();

或阅读更多here

相关问题