public IActionResult Get(string name, int height, int width, string watermark, string format) { ProductImage img; Logger.LogInformation($"Request for image Name:{name} Height:{height} Width:{width} Format:{format} with WaterMark:{watermark}"); try { img = Cache.TryGetImage(new ProductImage() { Name = name, Width = width, Height = height, Watermark = watermark, Format = SetFormat(format) }); } catch (FileNotFoundException e) { Logger.LogError($"Unable to locate file {name} - {e.Message}"); img = new ProductImage(); img.LoadBasic("Error/ImageNotFound"); } catch (ArgumentException e) { Logger.LogError($"Invalid Argument - {e.Message}"); img = new ProductImage(); img.LoadBasic("Error/InvalidParametersBottle"); } catch (Exception e) { Logger.LogError(e.Message); img = new ProductImage(); img.LoadBasic("Error/SomethingWentWrongBottle"); } return(new FileContentResult(img.BArr, $"image/{format.ToLowerInvariant()}") { FileDownloadName = $"{name}.{format.ToLowerInvariant()}" }); }