C# can';无法使用https获取web响应
我使用此代码获取web内容,但在C# can';无法使用https获取web响应,c#,ssl,https,certificate,C#,Ssl,Https,Certificate,我使用此代码获取web内容,但在WebResponse myResponse=myRequest.GetResponse()处获取异常 我知道它需要SSL/TLS证书,但我想知道为什么我仍然会出错 试试这个 static void Main(string[] args) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | Se
WebResponse myResponse=myRequest.GetResponse()处获取异常代码>
我知道它需要SSL/TLS证书,但我想知道为什么我仍然会出错
试试这个
static void Main(string[] args)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
var client = new HttpClient();
var result = client.GetAsync("https://www.ecfr.gov").Result;
var str = result.Content.ReadAsStringAsync().Result;
}
任何时候你“得到异常”你都需要告诉我们异常是什么。
static void Main(string[] args)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
var client = new HttpClient();
var result = client.GetAsync("https://www.ecfr.gov").Result;
var str = result.Content.ReadAsStringAsync().Result;
}