在一个窗口中托管多个 WebBrowser 控件会导致会话“交叉":有什么解决方案? [英] Hosting multiple WebBrowser controls in one window causes sessions to "cross": any solutions?

查看:45
本文介绍了在一个窗口中托管多个 WebBrowser 控件会导致会话“交叉":有什么解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用 VB.NET 编写的 Windows 窗体应用程序,我在同一窗口中托管多个 WebBrowser 控件.我遇到的问题是,每个 WebBrowser 控件的会话在发出异步请求时似乎会交叉",例如在加载图像时.例如,我有加载 HTML 文档的 WebBrowser1 和加载另一个 HTML 文档的 WebBrowser2.WebBrowser1 托管由 ASHX 页面提供的图像,并且依赖于浏览器会话.问题是,当请求 WebBrowser1 中的图像时,服务器实际上从 WebBrowser2 接收会话 ID.有没有办法强制每个 WebBrowser 控件具有唯一的会话?

I have a Windows forms application written in VB.NET where I host multiple WebBrowser controls in the same window. The problem I'm having is that the session for each WebBrowser control seem to get "crossed" when making asynchronous requests, such as when loading images. For instance, I have WebBrowser1 that loads an HTML document and WebBrowser2 that loads another HTML document. WebBrowser1 hosts an image that's served up by an ASHX page and is dependent on the browser session. The problem is that when the request is made for the image in WebBrowser1, the server actually receives the session ID from WebBrowser2. Is there a way to force each WebBrowser control to have a unique session?

推荐答案

WebBrowser 控件本质上只是 IE 的嵌入式版本.如果您启动常规 IE,请登录网站,然后启动 IE 的第二个副本并访问该网站,您会发现自己已使用第二个实例登录,因为 IE 跨实例共享 cookie.WebBrowser 控件也是如此.事实上,如果您使用 IE 登录网站,然后让 WebBrowser 控件进入该网站,您会发现它也已登录,因为 cookie 都是共享的.

The WebBrowser control is essentially just an embedded version of IE. If you launch the regular IE, log into a website, then launch a second copy of IE and visit the website you'll find yourself already logged in with the second instance because IE shares cookies across instances. The same is true of the WebBrowser control. If fact, if you log into a website with IE and then have the WebBrowser control go there you'll find that its been logged in, too, since the cookies are all shared.

所以基本上,AFAIK,你不能做你想做的事.

So basically, AFAIK, you can't do what you want.

这篇关于在一个窗口中托管多个 WebBrowser 控件会导致会话“交叉":有什么解决方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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