I had the below code in a SharePoint Webpart
and it worked properly:
using (var wb = new WebClient())
{
wb.UseDefaultCredentials = true;
var data = wb.DownloadData(@"http://sharepointSite/_layouts/15/Resources/Stamps/image.png");
}
If I try to use https
in browser like:
https://sharepointSite/_layouts/15/Resources/Stamps/image.png
After entering the credential I can download it:
but the problem is where I try to use https
in my code:
using (var wb = new WebClient())
{
wb.UseDefaultCredentials = true;
var data = wb.DownloadData(@"https://sharepointSite/_layouts/15/Resources/Stamps/image.png");
}
and I've got error:
The remote server returned an error: (401) Unauthorized.