1 Question: How to find the ip address of a user (public Ip address or server Ip address) in asp.net mvc5?

question created at Sat, Jun 1, 2019 12:00 AM

I am trying to find out the IP address of user not user's machine IP address instead of that need to find their server IP address but i am unable to find out.

0
  1. 2019-06-01 04:40:33Z
  2. "find their server IP address" ...what do you mean "server" in this context? A user connecting to your asp.net application is doing it from a machine running a browser. That machine is the "client" machine in this context. There is basically a direct connection between that machine and your webserver (apart from of course any routers/proxies which are placed in between). So in this context, precisely what do you mean by the user's "server"? it's unclear.
    2019-06-12 12:35:34Z
1 Answers 1
public string GetIPAddress()
 {
 IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName()); // `Dns.Resolve()` method is deprecated.
 IPAddress ipAddress = ipHostInfo.AddressList[0];

 return ipAddress.ToString();
}
1
2019-06-12 12:12:02Z
source placed here