添加HTTP标头和数据后在System.Windows.Forms.WebBrowser [英] Adding HTTP Headers and Post data in a System.Windows.Forms.WebBrowser

查看:180
本文介绍了添加HTTP标头和数据后在System.Windows.Forms.WebBrowser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用System.Windows.Forms.WebBrowser,使这两个发送POST数据以及自定义HTTP标头的请求。我想设置请求的用户代理。我怎么能这样做呢?

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?

推荐答案

您可以将使用此的导航超载​​。但有过申请表,完全控制包括用户剂和SUP pressing头,IE浏览器会默认将发送(如果甚至有可能),需要很多的互操作,你会更好只是滚动使用自己的要求HttpWebRequest和喂养输出到莫名其妙的浏览器。

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.

下面是定制一些额外的信息web浏览器。请注意,这是基于.NET WebBrowser控件的COM基础。对于所有,但最常见的情况,你需要去通过控件的IWebBrowser2接口,这意味着越来越熟悉COM互操作。这是不完全的乐趣,但它不是那么糟糕。

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.

这篇关于添加HTTP标头和数据后在System.Windows.Forms.WebBrowser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆