Use WebBrowserControl Capture Form Post

妖精的绣舞 提交于 2019-12-11 22:58:31

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/8423395/use-webbrowsercontrol-capture-form-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!