The remote server returned an error: (401) Unauthorized.
Posted
by Zaidman
on Stack Overflow
See other posts from Stack Overflow
or by Zaidman
Published on 2010-01-10T21:56:12Z
Indexed on
2010/05/07
7:38 UTC
Read the original article
Hit count: 1005
Hi I'm trying to get the html code of certain webpage, I have a username and a password that are correct but i still can't get it to work, this is my code:
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);
}
The MessageBox is just to test it, the problem is that every time I get to this line:
String htmlCode = client.DownloadString("http://cdrs.globalpopsvoip.com/0000069/20091229/20091228_20091228.CDR");
I get an exception:
The remote server returned an error: (401) Unauthorized.
How do I fix this?
© Stack Overflow or respective owner