可以让WebBrowser控件与HttpWebRequest共享cookie吗?
有没有办法让C#.NET中的WebBrowser控件和HttpWebRequest发出的请求共享cookie?
例如,如果使用 HttpWebRequest 以编程方式发出请求,然后 HttpWebResponse 设置 cookie,是否有办法确保这也在 WebBrowser 控件中设置?
同样,如果用户使用 WebBrowser 控件进行导航并设置了 cookie,是否有办法确保 HttpWebRequest 的 CookieContainer 也被更新?
感谢您的帮助!
is there a way to make the WebBrowser control in C#.NET and requests made by HttpWebRequest share cookies?
E.g. if a request is made programmatically with HttpWebRequest and then the HttpWebResponse sets a cookie, is there a way to make sure this is also set in the WebBrowser control?
and likewise, if the user navigates with the WebBrowser control and a cookie is set, is there a way to ensure the CookieContainer for the HttpWebRequest is also updated?
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用
InternetSetCookieEx / InternetGetCookieEx
API 手动同步 cookie,这需要您知道相关页面使用的所有子下载的所有 URL。您还需要传递
INTERNET_COOKIE_HTTPONLY
标志,以确保您的应用程序可以看到HTTPONLY
cookie。You'd need to synchronize the cookies manually using the
InternetSetCookieEx / InternetGetCookieEx
APIs, and this would require that you know all of the URLs of all of the subdownloads used by the page in question.You also need to pass the
INTERNET_COOKIE_HTTPONLY
flag to ensure thatHTTPONLY
cookies are seen by your application.(来源)
反之亦然(我不确定):
(source)
And vice versa (I'm not sure):