We’re having the following situation:
- a web site requires the user to log on (let’s call the site NPP)
- after the user logon, some links on the site open in new browser windows (let’s call the links ECR-s)
- an application uses a WebBrowser control to browse the site; if a logon is needed, the application simulates the user logon
- if the user clicks on an ECR link, a new browser window opens, but instead of displaying the content, it displays the site login page.
How can we make the browser automatically login to the NPP site in that scenario?
The answer came from a guy on MSDN forums (RudeDog2).
I’ve used the information from
http://support.microsoft.com/kb/815714 and http://blogs.artinsoft.net/mrojas/archive/2008/09/18/newwindow2-events-in-the-c-webbrowsercontrol.aspx to implement the solution: now the new browser windows open in the same process and, consequently, they inherit the in-memory session cookie.
One caveat, though: the application must be built x86 (and not ‘Any CPU’); if built ‘Any CPU’, either PDF files are not open in-browser, either ‘invalid image’ exceptions are raised.