Webrequest不使用SSL在IIS8上工作

时间:2015-06-06 08:52:29

标签: c# iis ssl

发送请求的代码及其呼叫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上部署它时,它无法发送请求。

1 个答案:

答案 0 :(得分:0)

问题解决了服务器上的问题。更新了IIS主机文件注释不必要的IP