I want to recreate a web browser with tab capability, popup block and redirection to a new tab.
Above the code of what I've been able to reach.
ATTEMPTS
I've tested it on some sites and the popup redirection on a new tab works but the new generated webBrowser seems to lost session authentication.
I suppose this could be due to the original webBrowser's cookies, that I can access through actualWebBrowser.Document.Cookie but I wasn't able to trasfer to the new browser.
I've tried newTabWebBrowser.ActiveXInstance = actualWebBrowser.ActiveXInstance; instead of ppDisp = actualWebBrowser.ActiveXInstance; which sounds very bad and can't compile because newTabWebBrowser.ActiveXInstance is read only.
WhilenewTabWebBrowser.Document.Cookie = actualWebBrowser.Document.Cookie;generate an error which doesn't block the application but skips my Browser_NewWindow3() function.
I've also foundInternetSetCookie(url, cookie); which has to be declared by[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)] static extern bool InternetSetCookie(string Url, string Cookie); Unfortunately I wasn't able to use these, maybe I miss some statements.
QUESTION
How can I force my new browser (inside new tab) to remember its "parent's" session/login information?
firstTabWebBrowser.Navigate("www.site-with-popup.com"); //inizialize my broeser navigation //... (firstTabWebBrowser.ActiveXInstance as SHDocVw.WebBrowser).NewWindow3 += new SHDocVw.DWebBrowserEvents2_NewWindow3EventHandler(Browser_NewWindow3); //new window 3 event //... private void Browser_NewWindow3(ref object ppDisp, ref bool Cancel, uint dwFlags, string bstrUrlContext, string bstrUrl){ Cancel = true; //blocks a new IE window to be openedTabPage addedTabPage = new TabPage("redirected tab"); //creates new tab tabControl_webBrowsers.TabPages.Add(addedTabPage); //add new tab to the TabControl System.Windows.Forms.WebBrowser newTabWebBrowser = new System.Windows.Forms.WebBrowser() //create new WebBrowser inside the new tab { Parent = addedTabPage, Dock = DockStyle.Fill }; System.Windows.Forms.WebBrowser actualWebBrowser = (System.Windows.Forms.WebBrowser)tabControl_webBrowsers.SelectedTab.GetChildAtPoint(new Point(10, 10)); //the only way I've found to select the actual webBrowser ppDisp = actualWebBrowser.ActiveXInstance; //try to pass actual browser reference to the new browser, but I can't notice any difference without this line newTabWebBrowser.Navigate(bstrUrl); //navigate to the popup destination url (newTabWebBrowser.ActiveXInstance as SHDocVw.WebBrowser).NewWindow3 += new SHDocVw.DWebBrowserEvents2_NewWindow3EventHandler(Browser_NewWindow3); //attach this function to the new browser }