I developed site. I need to get IP of site visitors. I try to use Request, but it have only internal IP:
Response.Write(Request.ServerVariables["REMOTE_ADDR"]);
I looked all keys in Server Variables collection - the same result:
foreach (string var in Request.ServerVariables)
{
Response.Write(Request[var]);
}
How can I get external IP address?
You can use like this
You can use it to get External (public) IP Address..
Are you behind a load-balancer/proxy? If so, inspect the headers collection of the request for headers similar to
X-FORWARDED-FOR
.This it part of my implementation for WebTracking. So here you go a snippet for IpAddress retrieval. You can read more about the Server Variables at Wikipedia.
you can simply use this nuget package. https://www.nuget.org/packages/IpPublicKnowledge/
easy and simple. here is an example :