views:

1001

answers:

2

I'm working on a webcrawler in VB.net, and using the System.Forms.WebBrowser object for handling navigation on sites that use javascript or form posts, but I'm having a problem. When I navigate backwards (WebBrowser.GoBack()) to a page that was loaded with a form post, the page has expired and I have to do a refresh to resend the request. When I call a refresh (WebBrowser.Refresh()), a dialog box pops up to confirm. Is there a way I can get around this modal dialog in code? Thanks!

+1  A: 

You may be able to pass in a refresh option of type System.Windows.Forms.WebBrowserRefreshOption .

There are several options, described here:
http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowserrefreshoption.aspx

It seems that the options are the only way you can control a web browser refresh programmatically.

Scott M.
I should have mentioned that I did try that, with IfExpired and Completely options selected, as well as the parameterless refresh which I believe is the same as Normal. I still see refresh prompts
Aaron K
A: 

I had a similar problem with a popup showing up with a javascript warning. I managed to suppress it using a windows_error event. I added this line to the browser_completed event handler

((WebBrowser)sender).Document.Window.Error += new HtmlElementErrorEventHandler(Window_Error);

Here is my window_error event handler:

 void Window_Error(object sender, HtmlElementErrorEventArgs e)
    {
        e.Handled = true;
    }

Another option to think about is toying around with this._browser.ScriptErrorsSuppressed. I'm pretty sure you aren't getting a script error, but it is worth a shot.

Sharath