HttpWebRequest 基础连接已关闭:接收时发生错误
作者:高景洋 日期:2017-07-28 18:42:42 浏览次数:3909
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
}
注:
1、ServicePointManager 在System.Net 命名空间下
2、SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 需在.net Framework 4.5 版本下才能支持
本文永久性链接:
<a href="http://r4.com.cn/art104.aspx">HttpWebRequest 基础连接已关闭:接收时发生错误</a>
<a href="http://r4.com.cn/art104.aspx">HttpWebRequest 基础连接已关闭:接收时发生错误</a>
当前header:Host: r4.com.cn
X-Host1: r4.com.cn
X-Host2: r4.com.cn
X-Host3: 127.0.0.1:8080
X-Forwarded-For: 3.144.117.52
X-Real-Ip: 3.144.117.52
X-Domain: r4.com.cn
X-Request: GET /art104.aspx HTTP/1.1
X-Request-Uri: /art104.aspx
Connection: close
Accept: */*
User-Agent: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Accept-Encoding: gzip, br, zstd, deflate