在ASP.NET中,MVC无法获得访问我网站的客户的DHCP分配的IP地址

发布于 2025-02-09 09:15:17 字数 476 浏览 2 评论 0原文

试图从我的网站构建ASP.NET MVC中访问另一台PC的客户端地址。 我已经使用了.NET的Bellow属性,但是当我检查了DHCP服务器分配的IP时,它仍在发送始终为127.0.0.1的客户地址。

  • request.userhostaddress
  • request.servervariobles [“ remote_addr”]
  • request.servervariables [“ http_x_forwarded_for”]

上述所有代码返回返回127.0.0.0.1,但您可以看到的真实IP地址。

Trying to access the clients ip address of another PC from my website build in ASP.NET MVC.
I have used the bellow properties of .NET but still it's sending the IP address of clients always 127.0.0.1 as I have checked the IP assigned by the DHCP server is different.

  • Request.UserHostAddress
  • Request.ServerVariables["REMOTE_ADDR"]
  • Request.ServerVariables["HTTP_X_FORWARDED_FOR"]

all of the above codes return 127.0.0.1 but the real IP address you can see in the picture.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

池予 2025-02-16 09:15:17

我想您是通过Localhost或127.0.0.1在本地访问您的网站。
在这种情况下,您的客户端通过专用网络到达服务器,服务器只能看到127.0.0.1。

I suppose you are accessing your website locally through localhost or 127.0.0.1.
In that case your client reachs your server via private network and the server can only see 127.0.0.1.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文