"The remote server returned an error: (401) Unauthorized"

  • Thread starter Thread starter Sajjaya Kumar
  • Start date Start date
S

Sajjaya Kumar

Guest
Hi,


I have a console application which will help to download URL file using the System.Net.WebClient. I am having two site to download the file using username and password. using the below code i am able to download the file from one site however, i am not able to download the URL file from the second site, its trowing the exception "The remote server returned an error: (401) Unauthorized". i am providing correct credentials ( I have checked manually to down load file using the credentials). Using .net framewok version 4.6. Below is the sample code which i am using.

using (System.Net.WebClient client = new System.Net.WebClient())
{
client.Credentials = new System.Net.NetworkCredential(usr, pw);
client.DownloadFile(downloadURL, filePath);

}

Any help on this would be appriciate

Continue reading...
 
Back
Top