Home > Article > Backend Development > Analyze C# httpwebrequest access HTTPS error handling method
The following editor will bring you an articleC#httpwebrequest access HTTPSError handlingmethod. The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let's follow the editor and take a look.
C# httpwebrequest encounters this error when accessing the HTTPS link, but if I open a packet capture tool, such as filddler2, the POST returns a normal
error The prompted message is:
The underlying connection has been closed: An error occurred while sending.
InnerException is:
Unexpected EOF or 0 bytes received from the transport stream.
After trying N methods on the Internet, the following is the solution this time:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
List the solutions found online, maybe they can solve your problem
The following are the solutions found online:
1. request.ProtocolVersion = HttpVersion.Version10;
2. ServicePointManager .ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
3.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
4.Try using another UserAgent
5.In App.config Add the following:
<system.net> <settings> <httpWebRequest useUnsafeHeaderParsing="true"/> </settings> </system.net>
The above is the detailed content of Analyze C# httpwebrequest access HTTPS error handling method. For more information, please follow other related articles on the PHP Chinese website!