0

I'm trying to get the remote Ip address

On Startup.cs

 app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
            });

Then I use Request.HttpContext.Connection.RemoteIpAddress.ToString() to retrieve the IP. I publish to the hosting and it returns wrong IP, somewhere in Hongkong instead of my real IP in other Asian country. I checked with a few pc in different location, all shows wrong IP.

nam vo
  • 3,271
  • 12
  • 49
  • 76
  • 1
    IP address to exact location is not reliable. – Win Aug 04 '17 at 13:04
  • Few other people also have asked same question : https://stackoverflow.com/questions/28664686/how-do-i-get-client-ip-address-in-asp-net-core https://stackoverflow.com/questions/34359109/get-the-clients-ip-address If I am correct you are not looking for ipaddress to location mapping. – dotnetstep Aug 05 '17 at 01:23

0 Answers0