【发布时间】:2011-01-05 04:58:22
【问题描述】:
我知道将证书添加到 HttpWebRequest 非常简单。但是,我还没有找到使用 WebClient 进行等效操作的方法。基本上,我想使用 WebClient 发送带有特定证书的 POST。
你将如何使用 WebClient 完成这个确切的代码:
var request = (HttpWebRequest) WebRequest.Create("my-url");
request.Method = "POST";
request.ClientCertificates.Add(new X509Certificate()); //add cert
【问题讨论】:
-
注意未来的答案寻求者,微软建议使用较新的 HttpClient 而不是 WebClient:We don't recommend that you use the WebClient class for new development. Instead, use the System.Net.Http.HttpClient class.
标签: c# httpwebrequest certificate webclient http-post