使用 WebBrowserControl 捕获表单帖子
我正在为一个专门的系统开发一个 Html/Http 检查 UI。我想知道是否有人知道如何从代码中捕获 WebBrowserControl 内部生成的 POST 值,以捕获发布的值和帖子的位置(操作)。我并不是在寻找一种工具,因为 Fiddler 和 Firebug 的 Net 面板都可以完美地完成此操作,我正在寻找一种使用 WebBrowserControl 从 .Net 捕获和记录代码中的帖子的方法。有办法做到这一点吗?
注意:我当前版本的该工具读取并检查 HTMLDocument 上存在的表单/值,但这还不够,因为通常可以通过脚本动态提交表单并更改操作/表单值,或者提交到不同的隐藏或动态创建的形式。
如果这是唯一的方法,我愿意拥有一个正在进行的 http 检查库/代码/代理。任何建议将不胜感激。
I am working on an Html/Http inspection UI for a specialized system. I am wondering if someone knows how to capture the values of a POST generated inside of a WebBrowserControl from code to trap what values were posted and the location(action) of the post. I am not looking for a tool as Fiddler and Firebug's Net panel both do this beautifully, I am looking for a way to capture and record posts in code from .Net using the WebBrowserControl. Is there a way to do this?
Note: My current version of this tool reads and inspects forms/values present on the HTMLDocument, but it is not sufficient since often forms can be dynamically submitted via script and have the action/form values altered, or submit to a different hidden or dynamically created form.
I am open to having an in process http inspection library/code/proxy in place if that is the only way to do this. Any suggestions would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的。这篇文章http://social.msdn.microsoft.com/forums/en-US/winforms/thread/eab43afa-df4d-4278-926a-b07d2d6ca9fd/ 引导我扩展实现codeproject here 它包装了 WebBrowserControl 并公开了扩展的 DWebBrowserEvents2 事件数据,其中包含 postData 和标头预导航,以便您可以捕获它们。我确实必须扩展该示例的 BrowserExtendedNavigatingEventArgs 实现来处理 postData 和标头,但这很简单。
希望这可以帮助其他人。
OK. This post http://social.msdn.microsoft.com/forums/en-US/winforms/thread/eab43afa-df4d-4278-926a-b07d2d6ca9fd/ led me to an extended implementation of the WebBrowser control on codeproject here which wraps the WebBrowserControl and exposes the extended DWebBrowserEvents2 event data which contains the postData and headers pre-navigation so that you can capture them. I did have to extend that example's implementation of BrowserExtendedNavigatingEventArgs to handle postData and headers but that was trivial.
Hopefully this helps someone else out.