1

We have a WebBrowser that needs to have login information reset.

There is a solution in this question that suggests using INTERNET_HANDLE_TYPE_INTERNET with INTERNET_OPTION_END_BROWSER_SESSION. However, I'm not sure where INTERNET_HANDLE_TYPE_INTERNET should go.

private const int INTERNET_OPTION_END_BROWSER_SESSION = 42;
private const int INTERNET_HANDLE_TYPE_INTERNET = 1;

[DllImport("wininet.dll", SetLastError = true)]
private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, 
    IntPtr lpBuffer, int lpdwBufferLength); 

I call it right before I navigate:

InternetSetOption(IntPtr.Zero, INTERNET_OPTION_END_BROWSER_SESSION, IntPtr.Zero, 
    0);              
browserCtrl.WebBrowser.Navigate(loginUrl);
Community
  • 1
  • 1
tofutim
  • 22,664
  • 20
  • 87
  • 148
  • You cannot get that handle from WebBrowser. I seriously doubt IE still uses WinINet. Try creating a new instance of WB instead. – Hans Passant Nov 12 '11 at 18:50
  • That's the problem, even when you create a new instance of WB, it retains the login session information. Using INTERNET_OPTION_END_BROWSER_SESSION solves this problem, but I'm concerned it will affect other applications like Office. – tofutim Nov 12 '11 at 19:22

0 Answers0