how to fix .net core get ip ::1

--

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();
}

--

--

Jameskrauser Lee
Jameskrauser Lee

Written by Jameskrauser Lee

For the last few years. i was involved mostly in the development of Automatic Fare collection system for the Chennai Metro. Familiar with C++ and iOS.

No responses yet