public async Task <IActionResult> DownloadTechNoteFile(int id) { var techNote = await _techNoteService.GetTechNoteById(id); string filename = techNote.m_file_guid; if (filename == null) { return(Content("filename not present")); } var TechNotesUserFilePath = _configuration["UserFilePath:TechNotesFiles"]; var rootPath = _hostingEnvironment.WebRootPath; var path = Path.Combine( rootPath, TechNotesUserFilePath, filename); var memory = new MemoryStream(); using (var stream = new FileStream(path, FileMode.Open)) { await stream.CopyToAsync(memory); } memory.Position = 0; return(File(memory, FileUploadHelper.GetContentType(path), techNote.m_file_name)); }