我正在构建一个 ASP.NET 应用程序
如果我在远程连接中运行网站,我从 System.Web.HttpContext.Current.Request.UserHostAddress
获得的 Ip 是什么?是我本地网络的ip还是远程电脑连接的网络的ip?
我需要检测用户实际使用的网络的 ip,而不是远程计算机的 ip。
有什么想法吗?
最佳答案
Is it the ip of my local network or the ip of the network that the remote computer is connected?
这将是本地IP。
I need to detect the ip of the network that the user is actually using, not the one of the remote compute
忘掉这个要求吧。此信息不是 HTTP 协议(protocol)规范的一部分,永远不会发送到服务器。您将需要在您的网站上提供一个输入字段,您可以在其中要求用户输入此信息,或者在服务器上运行一些桌面应用程序,用于检测远程连接用户的 IP,然后启动默认 Web例如,通过导航到您的 Web 应用程序并将其作为查询字符串参数传递给浏览器。
您可能会考虑的另一种可能性是使用某种 ActiveX 控件来检索此信息。但是我们都知道 ActiveX 带来的限制。
关于c# - 远程桌面连接中的用户 IP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12723487/