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;

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
    Commented Sep 26, 2017 at 3:14


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.