views:

35

answers:

1

Hello!

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?

Thanks!

+1  A: 

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.

Josh Einstein
I was thinking that would be the answer. Navigate really doesn't give you too much power.
Gbps