In my application, user will open multiple tabs by clicking on menus. Each tab is dynamically created and containing webbrowser control to load URL.
Each URL point to same server and some of URL does not have access so , gives Resource not have access
error received.
Now, problem is, example- If user directly click on Menu3
and related tab loaded with webbrowser URL and follow to next, URL contain other popup link then it works and able to popup the URL.
Now, user click on Menu5
where not have access so, get this error Resource not have access
(denied from server). Its fine.
NOw, again URL reach to
Menu3and try to open sub link to popup dialog then it gives
403 forbidden error- decline access`. It works initially but, later it just giving this error.
As it looks, I need to clear the WebBrowser Control
cache or forcely start with new session.
Can any one please guide me how to force WebBrowser to start new session or remove earlier caches ?
There is a better alternative. It's using the WinINet.DLL and calling SetInternetOptions
[DllImport("wininet.dll", SetLastError = true)]
private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int lpdwBufferLength);
private const int INTERNET_OPTION_END_BROWSER_SESSION = 42;
InternetSetOption(IntPtr.Zero, INTERNET_OPTION_END_BROWSER_SESSION, IntPtr.Zero, 0);
This will end the browser's session cache. After you call this method the webbrowser control will forget whatever sessions had in memory
The cache of the WebBrowser control is the same of Internet Explorer. You have various options:
1) Completely clear that cache (will also clear Internet Explorer!):
https://stackoverflow.com/a/24401521/2633161
2) Use some tags in the server response:
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
3) Use a random query string to force the refresh:
WebBrowser1.Navigate('http://www.example.com/?refresh=' & Guid.NewGuid().ToString())
4) Force refresh of the page (this will load the page 2 times!):
WebBrowser1.Navigate('http://www.example.com/')
WebBrowser1.Refresh(WebBrowserRefreshOption.Completely)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With