/// <summary> /// Checks if a file exists in storefront folder, then client folder, then server folder, otherwise returns 404 /// </summary> /// <param name="path"></param> /// <returns></returns> protected ActionResult StoreFile(string path, bool isImage = false) { if (string.IsNullOrWhiteSpace(path)) { return(HttpForbidden("Directory Listing Denied: /")); } StoreFront storeFront = null; try { storeFront = base.CurrentStoreFrontOrThrow; } catch (Exception ex) { if (ex is GStoreData.Exceptions.StoreFrontInactiveException || ex.GetBaseException() is GStoreData.Exceptions.StoreFrontInactiveException) { //storefront is inactive, just show server file System.Diagnostics.Debug.Print("--StoreFile - StoreFront is inactive for file: " + path); } else if (ex is GStoreData.Exceptions.NoMatchingBindingException || ex.GetBaseException() is GStoreData.Exceptions.NoMatchingBindingException) { //no matching binding, just show server file System.Diagnostics.Debug.Print("--StoreFile - No matching binding found; for file: " + path); } else if (ex is GStoreData.Exceptions.DatabaseErrorException || ex.GetBaseException() is GStoreData.Exceptions.DatabaseErrorException) { //databse error. just show server file System.Diagnostics.Debug.Print("--StoreFile - Database Error: " + ex.Message + " - for file: " + path); } else { throw new ApplicationException("Error getting CurrentStoreFront for StoreFile controller.", ex); } } Client client = null; if (storeFront != null) { client = storeFront.Client; } string fullPath = storeFront.ChooseFilePath(client, path, Request.ApplicationPath, Server); if (string.IsNullOrEmpty(fullPath) && isImage) { path = "Images/NotFound.png"; fullPath = storeFront.ChooseFilePath(client, path, Request.ApplicationPath, Server); } if (string.IsNullOrEmpty(fullPath)) { return(HttpNotFound((isImage ? "Image" : "Store File") + " not found: " + path)); } string mimeType = MimeMapping.GetMimeMapping(fullPath); return(new FilePathResult(fullPath, mimeType)); }