我試圖從WCF服務訪問https://api.github.com/search/repositories?q=service+language:assembly%26sort=stars%26order=desc並得到the remote server returned an error (403) forbidden
異常。我已經嘗試加入httprequest.UseDefaultCredentials = true;
和 httprequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
但這些都沒有幫助到目前爲止。以下是使用的代碼。獲取遠程服務器返回的錯誤403禁止的異常
`HttpWebRequest httprequest = (HttpWebRequest)HttpWebRequest.Create("https://api.github.com/search/repositories?q=service+language:assembly%26sort=stars%26order=desc");
httprequest.Proxy = new WebProxy()
{
Address = new Uri(Proxy_address),
Credentials = System.Net.CredentialCache.DefaultNetworkCredentials
};
httprequest.UseDefaultCredentials = true;
httprequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
httprequest.KeepAlive = true;
HttpWebResponse GISTResponse = (HttpWebResponse)httprequest.GetResponse();`
請大家幫忙。
是什麼Proxy_address這裏? – Shetty