I am using the WebBrowser control inside a Windows Form to display a PDF.
Whenever the PDF is regenerated, however, the WebBrowser control only displays its local cached version and not the updated version from the server.
I am using the Refresh() method shown below to try and force the control to reload the PDF, but it doesn’t work:
_webBrowser.Navigate(pdfUrl);
_webBrowser.Refresh(WebBrowserRefreshOption.Completely)
Do I have to do anything else to force the refresh to reload the PDF from the server?
Sheng Jiang is correct – you need the programmatically clear IE’s cache. Here is sample code showing how to do this in c#:
http://www.gutgames.com/post/Clearing-the-Cache-of-a-WebBrowser-Control.aspx
Copy in case the page goes offline:
It is based heavily on the Microsoft KB article here:
http://support.microsoft.com/kb/326201
And to pre-empt the question – yes this is a huge pain in the neck, and no, there isn’t another way around it. Good luck!