private string GetIP() { string strHostName = ""; strHostName = System.Net.Dns.GetHostName(); IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(strHostName); IPAddress[] addr = ipEntry.AddressList; return addr[addr.Length - 1].ToString(); }
string clientIp = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if( !string.IsNullOrEmpty(clientIp) ) { string[] forwardedIps = clientIp.Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries ); clientIp = forwardedIps[forwardedIps.Length - 1]; } else { clientIp = context.Request.ServerVariables["REMOTE_ADDR"]; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)