1

I'm building an application in C# that makes use of the WebBrowser control. This is loading a specific page (that I did not create) that uses a popup and a cookie that determines what the last "ID" searched for was. This all works fine, except when Internet Explorer is open in the background. When Internet Explorer is open in the background, the popup only goes to the first ID ever set. It would appear that the cookies aren't being stored properly when IE is open.

Breakdown:

  • User opens Internet Explorer.
  • User opens My Application.
  • User searches for XXX on page.
  • User clicks popup. Popup displays the correct information.
  • User searches for XXY on parent page.
  • User clicks popup. Popup displays previous information (not correct).

As I said, this works fine when Internet Explorer is not open.

Does anyone know what might cause this or how to prevent it? Perhaps Internet Explorer is "locking" its cookies?

teynon
  • 7,540
  • 10
  • 63
  • 106

1 Answers1

1

As I often do, I discovered the problem while writing the question. This happened to be a caching issue specific to the WebBrowser Control when IE8 is installed.

This thread suggests clearing the cache of the URL before navigating. Using the following code:

using System.Runtime.InteropServices;
...
[DllImport("wininet.dll", SetLastError = true)]
private static extern long DeleteUrlCacheEntry(string lpszUrlName);

Then you can use

DeleteURLCacheEntry(pdfURL);
webBrowser.Navigate(pdfURL);
teynon
  • 7,540
  • 10
  • 63
  • 106