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> 

作者:冰封一夏
出处:http://www.cnblogs.com/bfyx/
HZHControls官网:http://www.hzhcontrols.com
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,
且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
GitHub:https://github.com/kwwwvagaa/NetWinformControl
码云:https://gitee.com/kwwwvagaa/net_winform_custom_control.git

原文地址:https://www.cnblogs.com/bfyx/p/15566646.html