How to disable caching in the .NET WebBrowser Cont

2019-02-12 22:06发布

I have been googling for hours and trying to figure this out, and I just can't. I have 1 webbrowser control on a form, webbrowser1.

Once I load a page, say google.com, if I use webbrowser1.refresh() or webbrowser1.navigate("google.com"), it's not reloading the page, it has it cached so it's just reloading the cache. This is terribly apparent especially on pages like forums or craigslist.

I need to clear the cache between each refresh (not ideal) or disable caching all together, any ideas? The only things I've found are outdated (vb6 or lower).

8条回答
霸刀☆藐视天下
2楼-- · 2019-02-12 22:32

use navigate(url,4) 0x4=noCache flag

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-02-12 22:33

You could try adding a random number or guid in the url as a parameter. Such as:

var url = "http://google.com";
webBrowser.Navigate(url + "?refreshToken=" + Guid.NewGuid().ToString());

It's not elegant, but it works. Hope it helps.

查看更多
登录 后发表回答