Haritha B

Haritha B

  • NA
  • 3
  • 739

Get Client Machine IPAddress if it is in a network

Jan 23 2019 11:44 PM
Hi All,
 
I have deployed .net application in Azure.I am using the below code to get Cleint machine IP address.It is working fine for personal systems but if i accessed the applicaiton from my office which is connected in a network ,I am getting same public ip for all systems in my office.
 
public string GetIPAddress()
{
IPHostEntry Host = default(IPHostEntry);
string Hostname = null;
Hostname = System.Environment.MachineName;
ViewBag.UserHostName = Hostname;
Host = Dns.GetHostEntry(Hostname);
foreach (IPAddress IP in Host.AddressList)
{
if (IP.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
{
IPAddress = Convert.ToString(IP);
}
}
return IPAddress;
}
 
I want to identify each individual IP who is accessing the applicaton. Can anyone help me how can I retrieve invidual system ip if I accessed from office also.
 
Thanks in advance...

Answers (2)