Web服务:403禁止的错误
本文关键字:错误 禁止 服务 Web | 更新日期: 2023-09-27 18:26:36
我正试图将服务中的一些数据访问到我的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服务!
它以前工作正常。但几天以来,它给出了错误
首先要检查的是:证书过期了吗?