I'm using the WebBrowser
control and when a user navigates to, for example, http://www.google.co.uk
I'd like to display the IP address of the host that user is "connected" to.
Presently, I wait for the DocumentComplete
event to fire, then use Dns.GetHostEntry("http://www.google.co.uk");
but this returns an AddressList
which is an array of IP addresses, not the actual IP the user is connected to. In this example, 16 IPv4 addresses are returned.
How do I get the IP address the user is connected to and not all the available addresses?
Code snippet:
private void browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
IPHostEntry Host = Dns.GetHostEntry("http://www.google.co.uk");
foreach(var ip in Host.AddressList)
Debug.WriteLine("Host address list: " + ip);
}