public IActionResult OnPostDownload() { // Checks type if (string.IsNullOrEmpty(Type)) { Message = "Choose a type"; return(Page()); } string fileName = cService.GetFileName(Type); string path = Path.Combine(Environment.ContentRootPath, DIRECTORY, fileName); if (System.IO.File.Exists(path)) { Message = "File downloaded"; IsSuccess = true; return(PhysicalFile(path, "application/json", fileName)); } Message = $"File {Type}.json not found"; IsSuccess = false; return(Page()); }