问题描述
大家好,
我的系统位于网络中,我的IP地址显示为192.168.1.37(来自系统).现在,如果我使用下面的代码
Hi Everybody,
My system is in a network and my ip Address it is showing 192.168.1.37 (from the system). Now if I use the below code
userid = Convert.ToInt64(SessionManager.LoggedInUserID);
IPHostEntry host;
string localIP = "?";
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily.ToString() == "InterNetwork")
{
localIP = ip.ToString();
}
}
我在本地获得了正确的结果,但在实时运行中,它正在使用服务器IP地址插入客户端IP地址.
但是当我使用以下代码时
I am getting the correct result in local, but in live it is taking the Server Ip address insted of client IP address.
But when I am using the below code
string localIP = Request.UserHostAddress;
对于在两种情况下使用的相同系统,它给出的结果ip为127.0.0.1.但是我还没有把它变成现实.我不知道它是否可以正常工作.但是它(第二个)在本地无法正常工作.
我还需要客户端系统的第一个结果.
任何帮助将不胜感激.
It gives the result ip as 127.0.0.1 for the same system used in both cases. But I have not put it in live. I dont know whether it will work properly or not. But it (2nd one) is not working properly in local.
I need the first result for client system also.
Any help will be appreciated.
推荐答案
这篇关于客户端IP地址跟踪问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!