asp.net core 生成文件下载

 1 public IActionResult down(int id, string filename)
 2         {
 3             string path = hostingEnvironment.WebRootPath + "/ContractFiles/" + id + "/" + filename;
 4 
 5            
 6             var contentType = "APPLICATION/octet-stream";
 7             
 8             FileStream fs = new FileStream(path, FileMode.Open);
 9             return File( fs, contentType, filename);
10             
11         
12         }

 

posted on 2023-04-05 12:00  码农at突泉  阅读(64)  评论(0编辑  收藏  举报