0
我想通過代理服務器連接URL,但是當我使用代理並嘗試獲取響應時,它返回(403)禁止。WebRequest代理 - 403禁止錯誤
沒有代理一切正常。
private void button1_Click(object sender, EventArgs e)
{
CookieContainer cookies = new CookieContainer();
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://wikipedia.com");
webRequest.Proxy = new WebProxy("41.217.193.6", 80);
webRequest.CookieContainer = cookies;
webRequest.Accept = "*/*";
webRequest.Timeout = 9000;
HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse(); /// <== The remote server returned an error: (403) Forbidden.
StreamReader responseReader = new StreamReader(response.GetResponseStream());
string sResponseHTML = responseReader.ReadToEnd();
Clipboard.SetText(sResponseHTML);
}
您是否設置了請求的憑據? – 2012-03-10 09:26:00