C# web references 调用出错 The underlying connection was closed: An unexpected error occurred on a send.

在调用web references的位置加上try  catch 后捕捉到 error  message : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

解决办法:

在调用web references 方法前加上下面这句代码

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

导致问题的原因: 服务端提供的API的安全传输协议为TLS1.2


版权声明:本文为jl1134069094原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。