Good I am wanting to obtain the ip of the machine.
For that I am making this code that when I run it from my website and publish it in my local IIS it works and gets me my IP of my machine.
IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());
String IP = Convert.ToString(localIPs[1]);
This is the url of my page that, when calculating, must obtain the ip of the machine that is doing the test.
but the moment I publish it on an external website, it means that it is entered on the internet.
I see that the IP of the IIS is obtained and not the IP of the user.
I hope you can help me.
/******************* Respect of Luciano Montañez *************************** ***/
Put this code.
String IP = Request.UserHostAddress;
Inside a controller, when you receive a request.- This comes inside the object
HttpContext.Request
Note: The fact of obtaining
"::1"
as a response is not an error, but this is returned while you dorequest/response
from the samelocalhost