【发布时间】:2021-06-10 06:16:54
【问题描述】:
我之前的 C# 项目目标是 .Net Framework 4.6.1,在窗口 7、8.1 和 10 中工作正常。但现在我将目标框架更改为 .Net Framework 4.8、Window 8.1 和 10 仍然没有问题,但窗口HTTP 请求中的 7 错误。
"An error occurred while making the HTTP request to https://Test.123.com/API/ServiceRouter.svc. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server."
备注:
- Http 请求操作只是从我的服务接收一些数据
- .Net Framework 4.8 已安装在 window 7 (SP 1) 平台中。
- 代码没有任何改变
【问题讨论】:
-
我发现了这个问题,这是因为 .NET Framework 4.7 中默认使用 TLS1.0、1.1 和 1.2。从 .NET Framework 4.7.1 开始,默认为操作系统配置的版本。所以我需要在 HTTP 请求之前添加这段代码。 "System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;"" docs.microsoft.com/en-us/dotnet/framework/network-programming/…
标签: httprequest .net-framework-4.8