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 标头和发布数据
基础教程推荐
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- SSE 浮点算术是否可重现? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01