我試圖獲取某些網頁的HTML代碼, 我有一個用戶名和密碼是正確的,但我仍然無法使它工作, 這是我的代碼:遠程服務器返回錯誤:(401)未授權
private void buttondownloadfile_Click(object sender, EventArgs e)
{
NetworkCredentials nc = new NetworkCredentials("?", "?", "http://cdrs.globalpopsvoip.com/0000069/20091229/20091228_20091228.CDR");
WebClient client = new WebClient();
client.Credentials = nc;
String htmlCode = client.DownloadString("http://cdrs.globalpopsvoip.com/0000069/20091229/20091228_20091228.CDR");
MessageBox.Show(htmlCode);
}
在MessageBox是隻是爲了測試它, 問題是,每次我去這個線時間:
String htmlCode = client.DownloadString("http://cdrs.globalpopsvoip.com/0000069/20091229/20091228_20091228.CDR");
我得到一個異常:
The remote server returned an error: (401) Unauthorized.
我該如何解決這個問題?
感謝它爲我工作 – 2017-07-06 10:36:02