public async Task <ActionResult <ImageObject> > Get(string ImageURL) { try { Color imageColor = Color.Transparent; using (var client = _httpClientFactory.CreateClient()) { using (HttpResponseMessage response = await client.GetAsync(ImageURL, HttpCompletionOption.ResponseHeadersRead)) { if (response.IsSuccessStatusCode) { using (Stream streamToReadFrom = await response.Content.ReadAsStreamAsync()) { imageColor = ImageProcess.ColorDetector(streamToReadFrom); //If I want to create a copy in file system. //string destinationPath = Path.Combine(_hostEnvironment.ContentRootPath, @"downloads\test1.png"); //using (Stream streamToWriteTo = System.IO.File.Open(fileToWriteTo, FileMode.Create)) //{ // await streamToReadFrom.CopyToAsync(streamToWriteTo); //} } } else { return(NotFound("Check your image URL")); } } } //ImageProcess.ColorDetector(destinationPath); ColorModel ProDigiColor = ImageProcess.GetColor(imageColor); var Output = new ImageObject() { Key = ProDigiColor.Name, Color = ProDigiColor, }; return(Ok(Output)); } catch (Exception ex) { //I prefer to use Azure ApplicationInsight. I can follow requests, failures and performance as well set an alert. _logger.LogError(ex.Message, ImageURL); return(BadRequest(ex)); } }