0

is there a way to display the IP address of the web front end on a site's masterpage? I have a table at the bottom of my masterpage where I'd like to store the code. I'm running load-balancing and would like some indication of which server I'm hitting by displaying the WFE IP at the bottom.

Thanks.

0

You can use the following code snippet in your masterpage (replace Console.WriteLine with assigning text to your control):

String strHostName = string.Empty;
strHostName = Dns.GetHostName();
IPHostEntry ipEntry = Dns.GetHostEntry(strHostName);
IPAddress[] addr = ipEntry.AddressList;

for (int i = 0; i < addr.Length; i++)
{
    if (!addr[i].IsIPv6LinkLocal)
    {
        Console.WriteLine("IP Address: {0} ", addr[i].ToString());
    }
}

Also, I suggest you make the foreground color equal to background color. That way no one will see it and you'll be able to select it with mouse.

Source: https://stackoverflow.com/questions/6803073/get-local-ip-address

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.