Stopping WebBrowser forces Internet Explorer to open

I am using C # WebBrowser to show the Facebook login dialog for my desktop application. I am re-registered in the WebBrowser.DocumentCompleted event, and as soon as I get the expected URL, I will stop WebBrowser and close the dialog.

For some reason, after closing the dialog box, Internet Explorer opens unexpectedly.

I can only assume that it opens IE (which, by the way, is even my default browser), because the web server is returning the page, and my WebBrowser is already gone. This is true? Any idea how to prevent this?

Thanks!

Edit: When I close WebBrowser, it already contains HTML, which is displayed in IE.

+6
source share
2 answers

If it is a popup. Why not just handle this event? You could do something like this.

{... WebBrowser wb = new WebBrowser(); wb.NewWindow += new System.ComponentModel.CancelEventHandler(wb_NewWindow); } void wb_NewWindow(object sender, System.ComponentModel.CancelEventArgs e) { e.Cancel = true; } 
+3
source

This is because the page did not load successfully. Perhaps some script cannot be executed by the browser. Before you close WebBrowser or Form , where WebBrowser , open the "zero page". At:

 WebBrowser.url = new URl("about:blank"); 

then close the form, close or uninstall the browser.

0
source

Source: https://habr.com/ru/post/914099/


All Articles