使用WebRequest SSL进行401未经授权的异常

时间:2016-12-01 16:19:29

标签: c# ssl webrequest

我有以下C#代码尝试向特定网址发出https请求。如果我将URL更改为指向QAS服务器,而不是https,那么一切正常。我已尝试过多种设置组合,但我所做的一切似乎都无法正常使用。你可以看到我在评论中做过的几种不同的事物组合。

var request = (HttpWebRequest)WebRequest.Create(nextUrl);
request.AllowAutoRedirect = false;
request.UseDefaultCredentials = true;
request.KeepAlive = false;
//request.PreAuthenticate = true;
//request.Credentials = CredentialCache.DefaultNetworkCredentials;
//request.Credentials = new NetworkCredential("name", "pass", "domain");
ServicePointManager.ServerCertificateValidationCallback = AcceptAllCertifications;
HttpWebResponse response;
using (response = (HttpWebResponse)request.GetResponse())
{
    //Do Something
}

0 个答案:

没有答案