Image read from URL

Project: Borsig

--------------------------------- When using WebClient-------------------------------------------

ExtendedImageLinkTask
private Stream LoadProductImageStream(IProductImage image)
        {
            try
            {
                using (WebClient webClient = new WebClient())
                {
                    //  Download from Particular website expects a User-Agent header to be specified.                     
                    webClient.Headers["User-Agent"= "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)";
                    
                    var result = webClient.DownloadData(image.MediumImagePath);
                    Stream stream = new MemoryStream(result);
                    return stream;
                }
            }
            catch (Exception ex)
            {
                TaskLog.Current.Add(this"Error on image download" + ex.Message, LogPriority.Medium);
            }             
            return null;
        } 
    }


--------------------------------- When use HttpClient -------------------------------------------

using (HttpClient client = new HttpClient())
            {
                var url = "http://www.te.com/content/dam/te-com/catalog/part/214/184/371/2-1418437-1-t1.jpg/jcr:content/renditions/product-high-res.png";
 
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("*/*"));      //image/png
                HttpResponseMessage response = client.GetAsync(url).Result;
 
                if (response.IsSuccessStatusCode)
                {
                    System.Net.Http.HttpContent content = response.Content;
                }
                else
                {
                    throw new FileNotFoundException();
                }
            }