void EnsureFileCanBeAccessed(string path) { if (!fileAccessAuthorization.CanAccess(path)) { throw new HttpException(404, "File not found"); } }
void ThrowIfCannotRequestRawFile(string applicationRelativeFilePath, IFile file) { if (fileAccessAuthorization.CanAccess(file.FullPath)) { return; } throw new Exception( string.Format( "The file {0} cannot be requested. Implement {1} to configure which files are safe to request.", applicationRelativeFilePath, typeof(IConfiguration <IFileAccessAuthorization>).FullName ) ); }