請讓我知道如何獲取客戶端IP地址,ip地址
我已經嘗試了所有的東西下面,但我得到了相同的輸出:127.0.0.1
string strClientIP;
strClientIP = Request.UserHostAddress.ToString();
string strHostName = System.Net.Dns.GetHostName();
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
string ipaddress = string.Empty ;
ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (ipaddress == "" || ipaddress == null)
ipaddress = Request.ServerVariables["REMOTE_ADDR"];
如何獲得正確的IP?
http://stackoverflow.com/questions/2612591/i-am-getting-the-wrong-client-ip-address – 2010-04-19 19:12:16
的可能重複我有同樣的問題。我解決了這個博客文章:[如何使用ASP.net獲取客戶端系統的IP地址](http://dotnetstock.com/technical/how-to-get-ip-address-of-a-client- system-using-asp-net) – 2012-11-11 10:26:13