public ActionResult DownLoad() ???????{ ???????????var download = new Download(); ???????????using (DataClasses1DataContext db = new DataClasses1DataContext()) ???????????{ ?????????????download = ?db.Download.FirstOrDefault(); ???????????} ???????????string fileName = !String.IsNullOrWhiteSpace(download.Filename) ? download.Filename : "TestFile"; ???????????string contentType = !String.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream"; ???????????return new FileContentResult(download.DownloadBinary.ToArray(), contentType) { FileDownloadName = fileName + download.Extension }; ???????}
MVC下载文件
原文地址:http://www.cnblogs.com/opts/p/7872308.html