在ASP.NET中,MVC无法获得访问我网站的客户的DHCP分配的IP地址
试图从我的网站构建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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想您是通过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.