如何通过Asp.net从客户端网络适配器检索Mac和IP地址 [英] how to retrieve Mac and IP address from client network adapter by Asp.net

查看:79
本文介绍了如何通过Asp.net从客户端网络适配器检索Mac和IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想通过我的网页检索我的客户端Mac和IP地址。

任何人都可以帮助我或者至少引导我?

我在谷歌尝试过一些样品,但所有样品都返回我的主机IP。



先进,谢谢。

Hello everybody,

I want to retrieve my client Mac and IP address by my web page.
Anybody could help me or at least guide me?
I have tried some samples in google ,but all of them return my host IP .

In advanced,thanks.

推荐答案

您之前是否正确搜索过CP Q / A和/或Google搜索?谷歌本身提供了大约443万个结果。

如果没有,那么让我(正确)谷歌那为你! [ ^ ]



这个CP问题 [ ^ ]是最佳结果。
Have you searched the CP Q/A and/or Googled it "properly" before? Google itself gives about 4.43 million results.
If not then Let Me (properly) Google That For You![^]

And this CP Question[^] is the top result.


对于IP点击此处: http://www.etechpulse.com/2013/04 /how-to-get-ip-address-aspnet.html [ ^ ]。

但是只有当服务器和客户端在同一个服务器上时才可以将其解析为MAC VLAN - 如果它们之间没有路由器。在这种情况下,您可以使用ARP协议。点击此处: http://www.news2news.com/vfp/?example=585&ver=vcs [ ^ ]。

您可以从客户端获取MAC地址,但只能采用平台和浏览器相关的方式,因此不能以任何形式提供可靠性:http://www.nullskull.com/q/10054371/how-to-get-client-mac-address.aspx [ ^ ]。 我不知道你对MAC的意图是什么,但我建议你忘记它们。它不适合识别。它甚至不能保证是唯一的 - 并且可以在大多数NIC中进行更改。
For the IP check here: http://www.etechpulse.com/2013/04/how-to-get-ip-address-aspnet.html[^].
But you can resolve it to MAC only if the server and the client are on the same VLAN - if there is no router between them. In this case you can use ARP protocol. Check here: http://www.news2news.com/vfp/?example=585&ver=vcs[^].
You could get MAC address from client side, but only in a platform and browser dependent way, thus not reliable in any form: http://www.nullskull.com/q/10054371/how-to-get-client-mac-address.aspx[^]. I don't know what your intentions with the MAC were, but I suggest you forget them. It is not good for identification. It is not even guaranteed to be unique - and can be changed in most NICs.


我不认为在许多情况下让Mac变得那么容易(我没有'尝试了它,但是要检索客户端的IP地址,你可以做类似下面的事情。

I don't think getting Mac will be that easy in many scenarios(I haven't tried it yet),but to retrieve client's IP address,you can do something like below.
string ip = Server.HtmlEncode(Request.UserHostAddress);



这将为你提供ip作为字符串。



注意:



如果你从localhost运行它,你每次都会得到127.0.0.1。



问候..


This will give you ip as a string.

Note:

You will get 127.0.0.1 every time if you run it from localhost.

Regards..


这篇关于如何通过Asp.net从客户端网络适配器检索Mac和IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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