Home > Backend Development > C#.Net Tutorial > Analyze C# httpwebrequest access HTTPS error handling method

Analyze C# httpwebrequest access HTTPS error handling method

黄舟
Release: 2017-03-24 11:40:00
Original
2853 people have browsed it

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;
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template