'Get the IP address of Device connected
I have this method in C# API that is returning the IP of the device connected:
/// <summary>
/// Return IP address
/// </summary>
private string GetIP()
{
string IPAddress = "";
string Hostname = Environment.MachineName;
IPHostEntry Host = Dns.GetHostEntry(Hostname);
foreach (IPAddress IP in Host.AddressList)
{
if (IP.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
{
IPAddress = Convert.ToString(IP);
}
}
return IPAddress;
}
But in Azure, this end up grabbing the wrong IP address beause of appgateaway. How I can modify it to get the connect IP and also how to have this in BaseAPIController.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
