0

我正在尝试将一些数据从服务访问到我的windows service. 这是其中一个线程中的代码:

HttpWebRequest webrequest = HttpWebRequest.Create(url + "/data.json?auth_token=" + authenticationToken);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
System.Net.ServicePointManager.ServerCertificateValidationCallback =
               ((sender, certificate, chain, sslPolicyErrors) => true);

webrequest.Method = "GET";
webrequest.ContentType = "application/jsonp";

HttpWebResponse webresponse = (HttpWebResponse) webrequest.GetResponse();
Encoding enc = System.Text.Encoding.GetEncoding("utf-8");
StreamReader loResponseStream = new StreamReader(webresponse.GetResponseStream(), enc);

result = loResponseStream.ReadToEnd();

它以前工作正常。但是几天以来,它给出了错误: The remote server returned an error: (403) Forbidden. at System.Net.HttpWebRequest.GetResponse()

编辑:

如果我通过浏览器尝试请求,我会正确地得到响应,但不是通过 windowa 服务!

4

1 回答 1

0

它以前工作正常。但是几天以来,它给出了错误

首先要检查:证书是否过期?

于 2013-08-05T10:35:17.483 回答