This is sample code written in VB.NET using Visual Studio 2005 and targetting .NET framework 2.0.
The standard built in Webbrowser control is missing many key features of the unmanaged COM based control. This is likely due to the framework's need to work against versions of Internet Explorer from 5.x all the way up through 7 and on. However you can implement the missing features yourself by extending the existing browser control, and syncing up the events you want to know about, and firing off code when these events occur.
The 2 events this example covers are:
- NavigateError - When a navigation error occurs, for any reason, the managed browser gives no indication via an event that this has happened. Implementing this event back into the control allows you to know when navigation has failed.
- NewWindow2 - Allows you to specify another browser instance/window in your application to house a popup when a newwindow is being created either via javascript, or a regular anchor tag with a target set to _blank. The worst part about the managed browser control as it stands now in the framework, is that new windows are actually generated in a new instance of Internet Explorer. This means session data does not persist across popups, which will make many websites simply not work (or force you to sign in again on every popup window)
You can see this for yourself, by visiting a testing page I made. If you visit this page using the standard .NET webbrowser control, and click the link, you will see the session data is not carried over to the popup, however in my extended browser, the session data will persist, because the popup window is created as part of your application.
The test page is here: http://zerosandtheone.com/public_files/asp/sessiontest/
This also means you can customize the look of the popup window, which is pretty cool. Perhaps you want to make it look different, or add other controls to it.