i always receive the error message "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host." in response immediately.
the root cause of this error is the Web API implemented with .Net Framework 4.6 and later use the Security Protocol 1.2 by default.and Web application implemented with .net framework 4.5 and earlier will use security protocol 1.1 by default..
the fix of this issue is very easy. we just have to setup the security protocol before calling the web api.
the following snippet of code will do the job
ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;
No comments:
Post a Comment