I needed to get the IP address of my Asp.Net server. I mean the IP of the machine that have the IIS when my Asp.Net application is running.
So I googled and found this: [Stackoverflow] Getting the IP address of server in ASP.NET?
And got this code:
var hostName = System.Net.Dns.GetHostName();
var address = System.Net.Dns.GetHostEntry(hostName).AddressList.First().ToString();
Good. It works perfectly, but only in development and test environment. In homologation environment the variable hostName
gets correct value, but the address
gets: "::1"
.
It's a super weirdo string. I can't even guess what is happening.
Can someone tell me what I'm doing wrong or what I'm not seen?