我可以使用 WebBrowser 控件读取 Ajax 请求的内容吗?

发布于 2024-11-24 01:36:05 字数 335 浏览 5 评论 0原文

我正在尝试读取 C#/WinForms 中 WebBrowser 控件中 AJAX 响应的内容。导航/导航/等。事件似乎会触发,但它们不会提供对返回数据的任何访问权限。

有没有办法拦截请求并读取数据?

注意:如果我直接发送请求(使用 webBrowser.Navigate(ajaxUrl)),则会弹出 WebBrowser 控件,要求用户打开/保存页面(因为它具有内容处置标头),因此这不是一个选项。我尝试使用 WebClient/WebRequest 手动执行此操作,但无法使 cookie 正常工作(从 document.cookie 读取的 cookie 似乎与 AJAX 请求实际发送的 cookie 不匹配!)。

I'm trying to read the contents of an AJAX response in the WebBrowser control in C#/WinForms. The Navigating/Navigated/etc. events seem to fire, but they don't give any access to the data being returned.

Is there any way to intercept the requests and read the data?

Note: If I send the request directly (using webBrowser.Navigate(ajaxUrl)) the WebBrowser controls pops up asking the user to Open/Save the page (as it has a content-disposition header), so that isn't an option. I tried doing it manually with a WebClient/WebRequest, but I can't get the cookies to work correctly (the cookies I read from document.cookie do not seemto match the cookies actually sent with the AJAX request!).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飘落散花 2024-12-01 01:36:05

不可以,您无法使用 Web 浏览器控件的方法从 Web 浏览器控件捕获 XMLHTTPRequest。您可能想看看 http://www.fiddler2.com/core/

No, you cannot capture XMLHTTPRequests from the web-browser control using the methods of the Web Browser control. You might want to have a look at http://www.fiddler2.com/core/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文