下面小编就为大家带来一篇c# httpwebrequest访问https错误处理方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
C# httpwebrequest访问HTTPS链接时遇到这个错误,但是如果我开抓包工具,比如filddler2,则POST返回正常
错误提示的Message为:
基础连接已经关闭: 发送时发生错误。
InnerException为:
从传输流收到意外的 EOF 或 0 个字节。
试了网上的N种方法,以下是本次的解决方案:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
把网上找到的解决方案列一下,没准就能解决了你的问题
以下是网上找到的解决方案:
1. request.ProtocolVersion = HttpVersion.Version10;
2. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
3.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
4.换个UserAgent试试
5.在App.config中添加以下内容:
<system.net> <settings> <httpWebRequest useUnsafeHeaderParsing="true"/> </settings> </system.net>
以上就是分析C#httpwebrequest访问HTTPS错误处理的方法的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号