How to disable caching in the .NET WebBrowser Control?

后端 未结 8 1737
我寻月下人不归
我寻月下人不归 2021-01-04 20:01

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.

8条回答
  •  执笔经年
    2021-01-04 20:25

    In the .navigate method, you pass the number 2 (the no history flag) but this will only kill history for that navigation, won't kill history for when you follow links. If you want to kill history for links that are clicked on, then you can intercept navigation during beforenavigate event, cancel the navigation by setting cancel = true and then using the URL provided by the event, re doing the navigation using .navigate with the flag set to 2 again (the no history flag).

    As far as other cache items like cookies, the flags don't work (though they may have implemented this in current versions)... Soto kill all cache items you actually need to programmatically do this outside of the web browser control by querying user cache using other Apis and deleting it, perhaps during document complete event or when browsing is done.

    Also be aware that if you kill history using web browser control, the web browser controls .goback method will not work (as it uses the same history unfortunately, and doesn't keep another history list in memory)... So when doing a goback, it will act like there was nothing to go back to :/.

    Let me know if you need more help.

提交回复
热议问题