获取客户端计算机的IP地址不是服务器IP(通过服务器的IP地址访问)

时间:2015-09-21 03:11:46

标签: c# ip-address

我需要获取客户端计算机的IP地址而不是服务器IP。使用C#

我已经做过研究,没有提供正确的答案。 我试过了

string strHostName = System.Net.Dns.GetHostName();
    string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();

HttpContext.Current.Request.UserHostAddress;
HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

这些都不适合我。

我也尝试了javascript,将IP地址放在控件中并且正在工作。但是,在Page Load事件上执行时,不会捕获控制值。

0 个答案:

没有答案