I have a link given by an ONVIF ip camera that contains a snapshot taken by the said camera.
When I try to open this link on a browser like chrome, I get the following prompt:
When I try to load this image from a c# windows form picturebox, I get the following error:
Load:
picturebox0.Load(mySnapUrl);
Error:
System.Net.WebException: 'The remote server returned an error: (401) Unauthorized.'
I can see the image in my browser once I enter the appropriate username and password.
Is there any way I could load such an image in a picturebox?
EDIT 1:
I tried this solution to manually load the image on a web client in which I added credentials by hand and I still get the same error at the downloadData
line.
var webClient = new WebClient();
var credentialCache = new CredentialCache();
credentialCache.Add(new Uri(mySnapUrl), "Basic", new NetworkCredential(user, password));
webClient.Credentials = credentialCache;
var imgStream = new MemoryStream(webClient.DownloadData(mySnapUrl));//Error
picturebox0.Image = new System.Drawing.Bitmap(imgStream);