I'm trying to get the client(caller of web api) IP address in in my dotnet core web api. I'm getting the IP address as "::ffff:127.0.0.1" tested from different client networks. With localhost getting as ": ::1" I'm using the following code inside my action method :
var ipaddress = HttpContext.Features.Get<IHttpConnectionFeature>()?.RemoteIpAddress?.ToString();
Also tried with below code too:
var ipaddress = Request.HttpContext.Connection.RemoteIpAddress;
Getting the same results. How can we fetch the exact IP address in dotnet core web api ?