MVC Controller 下载文件

1,Controller中的方法

public FileResult DownloadRFQFile(string filename)
        {
            string folder = AppDomain.CurrentDomain.BaseDirectory + @"dataRFQReply";
           
            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;
原文地址:https://www.cnblogs.com/footmark/p/11010660.html