MVC Controller 下载文件

1,Controller中的方法

public FileResult DownloadRFQFile(string filename)
        {
            string folder = AppDomain.CurrentDomain.BaseDirectory + @"data\RFQReply\";
           
            byte[] fileBytes = System.IO.File.ReadAllBytes(folder + filename);
            return File(fileBytes, "application/zip", filename);
          
        }

2,cshtml 页面中执行方法,获取下载文件

var url = "DownloadRFQFile?filename=" + dataFN;
window.location.href = url;

 

posted @ 2019-06-12 16:50  简辞  阅读(1648)  评论(0编辑  收藏  举报