开发者

How do you inject a header using the Navigating event in WebBrowser

I'm trying to solve a problem where I'm intercepting a request in Navigating 开发者_如何学编程and want to inject an additional request parameter into that request before passing it off.

Here are the steps:

First I make a request via WebBrowser.Navigate(). I have an event handler to capture the Navigating event.

The request hits the Navigating event (before the actual request is made). I, at this point, want to either cancel the request and issue a new request with the added parameters, or somehow alter the current request to have the correct parameter.

Unfortunately I cannot simply call the Cancel event, and re-issue a Navigate call because of one problem. This request is from an iframe, so its one level deep, and the navigate call would clobber the end result of the document contents (as it would show only the iframe contents and not its parent's).

Any suggestions?


It seems impossible to inject a new parameter into a request on low level.

A recommended way is to alter html source of a page sends a request. For instance, add a hidden input field inside a form just after page is loaded. IMHO.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜