public ActionResult Index(string preset, string path) { if (string.IsNullOrEmpty(path)) { return(HttpNotFound()); } var imageFactory = new ImageFactory(preset, path); if (!imageFactory.IsValid()) { return(HttpNotFound()); } var requestETag = GetETagFromRequest(); if (!imageFactory.HasChanged(requestETag)) { return(new HttpStatusCodeResult(HttpStatusCode.NotModified)); } try { var imageResult = imageFactory.GetImageResult(); if (imageResult == null) { return(HttpNotFound()); } SetETagForResponse(imageFactory.GetETag()); return(imageResult); } catch { return(HttpNotFound()); } }