title: Prevent WebBrowser Control in C# from launching external IE pop-up when logging into Windows Live
body: <p>This is for a Desktop C# app in Visual Studio 2012.</p>
  
  <p>I need to use a WebBrowser control in C# to log into a Windows Live instance, getting the control to open the page is nothing, but signing in is causing me a headache.</p>
  
  <p>I've tried about 4 different suggestions gleaned from Google, but I'm not getting logged in properly. </p>
  
  <p>This is what I've got:</p>
  
  <pre><code>//FORM1 code
  //Added reference to 'Microsoft Internet Controls'
  using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  
  namespace WindowsFormsApplication3
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
              webBrowser1.Url = new Uri("http://digitbot.com/live/");
          }
          SHDocVw.WebBrowser nativeBrowser;
          protected override void OnLoad(EventArgs e)
          {
              base.OnLoad(e);
              nativeBrowser = (SHDocVw.WebBrowser)webBrowser1.ActiveXInstance;
              nativeBrowser.NewWindow2 += nativeBrowser_NewWindow2;
          }
          protected override void OnFormClosing(FormClosingEventArgs e)
          {
              nativeBrowser.NewWindow2 -= nativeBrowser_NewWindow2;
              base.OnFormClosing(e);
          }
  
          void nativeBrowser_NewWindow2(ref object ppDisp, ref bool Cancel)
          {
              var popup = new Form2();
              popup.Show(this);
              ppDisp = popup.Browser.ActiveXInstance;
          }
      }
  }
  
  
  
  //FORM2 code
  using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  
  namespace WindowsFormsApplication3
  {
      public partial class Form2 : Form
      {
          public Form2()
          {
              InitializeComponent();
          }
          public WebBrowser Browser
          {
              get { return webBrowser1; }
          }
      }
  }
  </code></pre>
  
  <p>This launches the login pop-up in the second window, but somehow it never seems to complete the process.</p>
  
  <p>Following the link in the code above in a browser should get you logged in and should show raw JSON of calendar events followed by a profile picture. I need to get the same result in the WebBrowser control.</p>
  
  <p>Any help would be great, I'm stuck.</p>