c# HttpWebRequest 解决 请求HTTPS慢

其实就几行代码

if (strUrl.StartsWith("https", StringComparison.OrdinalIgnoreCase))
            {
                request.Credentials = CredentialCache.DefaultCredentials;
                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                request.ProtocolVersion = HttpVersion.Version11;

                ServicePointManager.CheckCertificateRevocationList = true;
                ServicePointManager.DefaultConnectionLimit = 100;
                ServicePointManager.Expect100Continue = false;
            }

 app.config增加

 <system.net>   
    <defaultProxy   
        enabled="false"   
        useDefaultCredentials="false" >   
      <proxy/>   
      <bypasslist/>   
      <module/>   
    </defaultProxy>   
  </system.net> 

 

posted @ 2021-11-17 12:18  冰封一夏  阅读(968)  评论(0编辑  收藏  举报
HZHControls控件库官网:http://hzhcontrols.com