发送请求及其调用https的代码
request =(HttpWebRequest) WebRequest.Create(url);
request.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);
request.Timeout = 5000;
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36";
request.ProtocolVersion = HttpVersion.Version11;
public bool AcceptAllCertifications(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certification, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true;
}
此代码在我的本地系统上运行良好,但是当我们将其部署到 IIS 上时,它无法发送请求。
最佳答案
问题已解决,问题出在服务器上。更新IIS主机文件注释不必要的IP
关于c# - Webrequest 不适用于带 SSL 的 IIS8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30680850/