1

I'm wondering when we load a page with DotNetBrowser how can we get the IP address of the server that served that page load request.

Bigtoe
  • 3,372
  • 1
  • 31
  • 47

1 Answers1

1

DotNetBrowser itself does not provide the ability to detect the server IP address. However, you can do this using the 'System.Net' namespace from the .NET Framework. The following source code demonstrates how to do this:

class Program
{
    static void Main(string[] args)
    {
        Browser browser = BrowserFactory.Create();
        browser.LoadURL("google.com");

        browser.FinishLoadingFrameEvent += (sender, eventArgs) =>
        {
            if (eventArgs.IsMainFrame)
            {
                Uri uri = new Uri(eventArgs.ValidatedURL);
                IPAddress ip = Dns.GetHostAddresses(uri.Host).FirstOrDefault();
                if (ip != null)
                {
                    Console.WriteLine("{0} : {1}", eventArgs.ValidatedURL, ip);
                }
            }
        };

        Console.ReadKey();

        browser.Dispose();
    }
}
Eugene Yakush
  • 259
  • 4
  • 6