I have a razor web application and it's published in the IIS. The problem is that I need to save the IP of the pc from the users who are login into the app. My method that returns the IP is the following:
public static string GetLocalIPAddress()
{
var host = Dns.GetHostEntry(Dns.GetHostName());
foreach (var ip in host.AddressList)
{
if (ip.AddressFamily.ToString() == ProtocolFamily.InterNetwork.ToString())
{
return ip.ToString();
}
}
throw new Exception("No network adapters with an IPv4 address in the system!");
}
But when I check my database the IP returned is the IP of the server not the IP from the actual user. Do you know how to fix it?