I have a simple .net core web api with one action:
[Route(\"[action]\")]
public class APIController : Controller
{
// GET api/values
[HttpGet]
pu
There is a more accurate way when there are multi IP addresses available on the local machine. Connect a UDP socket and read its local endpoint:
string localIP;
using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, 0))
{
socket.Connect("8.8.8.8", 65530);
IPEndPoint endPoint = socket.LocalEndPoint as IPEndPoint;
localIP = endPoint.Address.ToString();
}