我试图获取某些网页的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