Adding HTTP Headers and Post data in a System.Windows.Forms.WebBrowser(在 System.Windows.Forms.WebBrowser 中添加 HTTP 标头和发布数据)
问题描述
我正在尝试使用 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?
推荐答案
您可以使用此 导航重载.但是要完全控制包括用户代理在内的请求表单并抑制 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.
这里是关于自定义网络浏览器.请注意,这是基于 .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.
这篇关于在 System.Windows.Forms.WebBrowser 中添加 HTTP 标头和发布数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 System.Windows.Forms.WebBrowser 中添加 HTTP 标头和发布数据


基础教程推荐
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01