如何使用 VB.NET 或 C# 将 ip 地址转换为 url
我想将ip地址转换为url。但我不知道该怎么做。
I want to convert ip address to url. But i can't figure it out how to.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我想将ip地址转换为url。但我不知道该怎么做。
I want to convert ip address to url. But i can't figure it out how to.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
目前还不完全清楚你想要什么 - 一个例子会很有帮助 - 但像这样简单的事情
很可能就足够了。
编辑:好的,听起来您正在尝试查找 IP 地址的名称。在某些方面,这非常简单:
但是,这不打印eggheadcafe.com。它打印出完全不同的内容:
就反向 DNS 查找而言,这是完全正确的(运行“nslookup 72.29.94.50”以查看相同的结果)...但这不是您想要的。
问题是,我相信这个 Eggheadcafe.com 是由虚拟主机提供服务的 - 尽管 Eggheadcafe.com 在该 IP 地址上提供服务,其他网站也是如此(至少可能如此)。当您在浏览器中访问 Eggheadcafe.com 时,它会解析为该 IP 地址,但还会在 HTTP 标头中指定主机名。
It's not entirely clear what you want - an example would have been helpful - but something as simple as:
would quite possibly be enough.
EDIT: Okay, it sounds like you're trying to find the name for an IP address. In some ways that's quite simple:
However, this doesn't print eggheadcafe.com. It prints something entirely different:
That's entirely correct in terms of a reverse DNS lookup (run "nslookup 72.29.94.50" to see the same result)... but it's not what you were looking for.
The problem is that I believe this eggheadcafe.com is served by virtual hosting - although eggheadcafe.com is served on that IP address, so are other websites (at least potentially). When you visit eggheadcafe.com in your browser, it resolves to that IP address but also specifies the host name in an HTTP header.
不确定您想要实现什么,但猜测您需要从 IP 解析主机名。
在这种情况下,您可以使用
Dns.GetHostEntry
方法。Not sure what you want to achieve but guess you need to resolve a host name from IP.
In this case you can use
Dns.GetHostEntry
method.单个 IP 上可能托管多个网站。但您可以使用以下方式获得默认值,
以下可能有助于开始:
http:// www.c-sharpcorner.com/UploadFile/uchukamen/IPAddHostConverter12052005041212AM/IPAddHostConverter.aspx
There are possibility of multiple website hosted on single IP. But you can get default using
Following might helpful to start with:
http://www.c-sharpcorner.com/UploadFile/uchukamen/IPAddHostConverter12052005041212AM/IPAddHostConverter.aspx