Adding HTTP Headers and Post data in a System.Windows.Forms.WebBrowser
Asked Answered
S

1

2

I'm trying to use the System.Windows.Forms.WebBrowser to make a request that both sends POST data and custom HTTP headers. I'd like to set the user-agent of the request as well. How could I do this?

Sobranje answered 25/9, 2010 at 16:37 Comment(0)
M
2

You can send POST data and additional HTTP headers using this Navigate overload. But to have complete control over the request form including user agent and suppressing headers that IE will send by default would (if even possible) require so much interop that you'd be better off just rolling your own requests using HttpWebRequest and feeding the output into the browser somehow.

Here is some additional information on customizing the WebBrowser. Note that this is based on the COM underpinnings of the .NET WebBrowser control. For all but the most common scenarios you need to go through the control's IWebBrowser2 interface which means getting familiar with COM interop. It's not exactly fun, but it's not that bad.

Monogamist answered 25/9, 2010 at 16:44 Comment(1)
I was thinking that would be the answer. Navigate really doesn't give you too much power.Sobranje

© 2022 - 2024 — McMap. All rights reserved.