我正在尝试使用HTTPWebRequest
访问REST服务,但是在传递凭证方面遇到了问题,请参见下面的代码。我已经阅读了NetworkCredential
不支持SSL,并且我正在访问一个HTTPS站点。是否有人知道类似于NetworkCredential
但支持SSL的类?
Uri requestUri = null;
Uri.TryCreate("https://mywebserver/webpage", UriKind.Absolute, out requestUri);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(requestUri);
NetworkCredential nc = new NetworkCredential("user", "password");
request.Credentials = nc;
request.Method = WebRequestMethods.Http.Get;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();