how to fix .net core get ip ::1
Nov 15, 2023
ip ::1 = 127.0.0.1
string ServerIpv4 = baseController.HttpContext.Connection?.RemoteIpAddress?.ToString();
if (ServerIpv4 == "::1")//::1 = 127.0.0.1
{
string strHostName = System.Net.Dns.GetHostName();
ServerIpv4 = System.Net.Dns.GetHostAddresses(strHostName).GetValue(1).ToString();
}