.NET C#: WebBrowser control Navigate() does not load targeted URL

Posted by Dave on Stack Overflow See other posts from Stack Overflow or by Dave
Published on 2010-04-30T20:12:13Z Indexed on 2010/04/30 20:17 UTC
Read the original article Hit count: 876

Filed under:
|
|
|
|

Hey guys,

I'm trying to programmatically load a web page via the WebBrowser control with the intent of testing the page & it's JavaScript functions. Basically, I want to compare the HTML & JavaScript run through this control against a known output to ascertain whether there is a problem.

However, I'm having trouble simply creating and navigating the WebBrowser control. The code below is intended to load the HtmlDocument into the WebBrowser.Document property:

WebBrowser wb = new WebBrowser();
wb.AllowNavigation = true;

wb.Navigate("http://www.google.com/");

When examining the web browser's state via Intellisense after Navigate() runs, the WebBrowser.ReadyState is 'Uninitialized', WebBrowser.Document = null, and it overall appears completely unaffected by my call.

On a contextual note, I'm running this control outside of a Windows form object: I do not need to load a window or actually look at the page. Requirements dictate the need to simply execute the page's JavaScript and examine the resultant HTML.

Any suggestions are greatly appreciated, thanks!

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET