MVC下载文件
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 };
}