我可以使用 WebBrowser 控件读取 Ajax 请求的内容吗?
我正在尝试读取 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不可以,您无法使用 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/