我如何在asp.net服务器/网站的IP地址? [英] How do I get the server/website IP address in asp.net?

查看:133
本文介绍了我如何在asp.net服务器/网站的IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户请求时,我可以用Context.Request.UserHostAddress来获取用户的IP地址。我怎样才能在运行的网站/服务器的IP地址?我有一些报告code,可以在同一台服务器上使用多个网站,每个网站使用不同的IP地址。所以,我需要能够在运行时检测网站的IP地址。

When a user request comes in, I can use Context.Request.UserHostAddress to get the user's IP address. How can I get the IP address of the website/server at runtime? I have some reporting code that can be used by multiple websites on the same server, and each website uses a different IP address. So I need to be able to detect the website's IP address at runtime.

推荐答案

感谢亚历克斯,你的回答让我在​​正确的道路上。这里是code做什么,我在寻找:

Thanks Alex, your answer put me on the right path. Here is the code to do what I am looking for:

VB.NET:

System.Net.Dns.GetHostAddresses(Request.Url.Host)(0).ToString()

System.Net.Dns.GetHostEntry(Request.Url.Host).AddressList(0).ToString()

这篇关于我如何在asp.net服务器/网站的IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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