写在前面
在模拟请求的时候,如果url为https的,会报这个错误。大概错误就是:基础连接已关闭:无法建立信任关系的SSL / TLS的安全通道。
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
基础连接已关闭:无法建立信任关系的SSL / TLS的安全通道。
解决办法
在模拟请求的方法中加上这样一句话。
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback((obj, certificate, chain, sslPolicyErrors) => { return true; });
参考:http://robertgreiner.com/2013/03/could-not-establish-trust-relationship-for-the-ssl-tls-secure-channel/