WebClient webClient = new WebClient();
webClient.DownloadData(args[0]);
returns {"The remote server returned an error: (401) Unauthorized."}Adding this solves the problem.
webClient.UseDefaultCredentials = true;
Without this line of code, the client does not know which credentials to take and will call the site anonymously.
Credits go to: http://stackoverflow.com/questions/2150161/webclient-generates-401-unauthorized-error
No comments:
Post a Comment