如何强制WebBrowser控件使用“新建会话”或“清除会话” [英] How to Force WebBrowser Control to use New Session or clear sessions

查看:117
本文介绍了如何强制WebBrowser控件使用“新建会话”或“清除会话”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,用户将通过单击菜单来打开多个选项卡。
每个选项卡都是动态创建的,并包含 webbrowser控件以加载URL。

In my application, user will open multiple tabs by clicking on menus. Each tab is dynamically created and containing webbrowser control to load URL.

每个URL都指向同一服务器,某些URL确实没有访问权限,因此,给出资源没有访问权限错误。

Each URL point to same server and some of URL does not have access so , gives Resource not have access error received.

现在,问题出在例如-如果用户直接单击 Menu3 以及加载了Web浏览器URL的相关选项卡,然后继续下一步,该URL包含其他弹出链接,然后它可以工作并且能够弹出该URL。

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.

现在,用户单击 Menu5 那里没有访问权限,因此,出现此错误资源没有访问权限(从server 拒绝)。没关系。
现在,再次到达URL
Menu3 并尝试打开子链接到弹出对话框,然后它提供 403禁止的错误拒绝访问。 。

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 toMenu3and try to open sub link to popup dialog then it gives403 forbidden error- decline access`. It works initially but, later it just giving this error.

看起来,我需要清除 WebBrowser控件缓存或强制从新会话开始。

As it looks, I need to clear the WebBrowser Control cache or forcely start with new session.

有人可以指导我如何强制 WebBrowser 开始新的会话或删除早期的缓存吗?

Can any one please guide me how to force WebBrowser to start new session or remove earlier caches ?

推荐答案

WebBrowser控件的缓存与Internet Explorer相同。您有多种选择:

The cache of the WebBrowser control is the same of Internet Explorer. You have various options:

1)完全清除缓存(还将清除Internet Explorer!):

1) Completely clear that cache (will also clear Internet Explorer!):

https://stackoverflow.com/a/24401521/2633161

2)在服务器响应中使用一些标签:

2) Use some tags in the server response:

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">

3)使用随机查询字符串来强制刷新:

3) Use a random query string to force the refresh:

WebBrowser1.Navigate('http://www.example.com/?refresh=' & Guid.NewGuid().ToString())

4)强制刷新页面(这将加载页面2次!):

4) Force refresh of the page (this will load the page 2 times!):

WebBrowser1.Navigate('http://www.example.com/')
WebBrowser1.Refresh(WebBrowserRefreshOption.Completely)

这篇关于如何强制WebBrowser控件使用“新建会话”或“清除会话”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆