I'm creating a web application where I need a functionality that if someone client log in to my website the client's public IP address must be logged. I have some javascript to do this but some of my pal not agree to use a javascript library reason they don't trust it. Such as http://l2.io/ip.js?var=myip as mentioned here
So we need all of it as server side code. So i found few more code in this link but unfortunately I'm not getting the expected result (it only returns local hosts IP). Could anyone help me to solve this please.
I have tried the bellow code
string VisitorsIPAddr = string.Empty; if (HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null) { VisitorsIPAddr = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString(); } else if (HttpContext.Current.Request.UserHostAddress.Length != 0) { VisitorsIPAddr = HttpContext.Current.Request.UserHostAddress; } but this is not providing me the public IP. Do I need to deploy it or something.
HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]is always null