Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stopping a WebBrowser causes Internet Explorer to be opened

Tags:

browser

c#

.net

I'm using a C# WebBrowser in order to show a Facebook login dialog for my desktop application. I'm regeistered on the WebBrowser.DocumentCompleted event, and once I get the URL I'm expecting, I stop the WebBrowser, and close the dialog.

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

I can only assume that it opens up IE (which is by the way, not even my default browser) because the web server returns the page, and my WebBrowser is already gone. Is that the case? Any idea how to prevent it?

Thanks!

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

like image 655
Mobe Avatar asked Apr 25 '12 07:04

Mobe


People also ask

Why Internet Explorer keeps opening?

Sometimes, Internet Explorer and Edge can automatically open if your computer is infected with malware, as such threats tend to hijack web browsers, and open tabs without your input.

How do I stop Edge from redirecting to Internet Explorer?

you can go to Settings > Default browser > Let Internet Explorer open sites in Microsoft Edge and set it to Always (Recommended). If that didn't work, try to set "Allow sites to be reloaded in Internet Explorer mode" to Default or Allow and see if that fixes the problem.

How do I stop Internet Explorer Edge from opening in Windows 10?

Go to Advanced > Under settings, look for the setting "Hide the button (next to the New Tab button) that opens Microsoft Edge" and check the box.


1 Answers

If it's a popup. Why not just handle the 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;
}
like image 171
Michiko Avatar answered Nov 09 '22 19:11

Michiko