1

I am trying to use the below code to download and read the bytes of a document using System.NET.WebClient class. The file is in a SharePoint document library and the web application is using SSL. The code throws the exception 404 not found when executing the last line below.

WebClient webClient = new WebClient();
webClient.UseDefaultCredentials = true;
webClient.DownloadData("https://sharepointwebsite/document-library/Test.docx");

The program is running in the context of System Account user and if I try to access the above URL in the browser it works and downloads the file. What settings do I need to do in IIS or in my code for it to work? This works on a separate box for the same website but without SSL.

Thanks !

  • Does your SharePoint work on http? If yes, try the DownloadData method with http and see if it works? This is to make sure the issue is with https or http. – Ahmad Zia Sep 26 '17 at 3:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.