我得到了错误的客户端IP地址 [英] I am getting the wrong client IP address

查看:99
本文介绍了我得到了错误的客户端IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行的ASP.NET应用程序。该网站的服务器位于同一系统上。在code后面,我只是想获得请求的客户端的IP地址。我用这code:

I am running an ASP.NET application. The web server is located on the same system. In the code behind I just want to get the IP address of the requesting client. I am using this code:

Request.UserHostAddress

不过,我得到一个错误的地址: 127.0.0.1 。我的系统IP地址是 198.162.0.27

But I am getting a wrong address: 127.0.0.1. My system IP address is 198.162.0.27.

推荐答案

您所得到的是正确的。 127.0.0.1 的环回IP地址,这是在主机映射文件为localhost。

You are getting the right one. 127.0.0.1 is the loopback IP address, which is mapped in your hosts file to localhost.

如果您从远程计算机连接,您将获得远程计算机上的网络地址。

If you connect from a remote computer, you will get the remote computers network address.

这篇关于我得到了错误的客户端IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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