我有这种控制器方法,它运行良好,但它在浏览器中显示该文件,我想强行下载而不显示它,那么要改变什么?
public ActionResult DownloadFile(int id, string Url)
{
var b = db.Books.FirstOrDefault(s => s.Book_id == id);
WebClient client = new WebClient();
var fileStream = client.OpenRead(b.pdf_file);
return new FileStreamResult(fileStream, "application/pdf");
}
答案 0 :(得分:0)
将其更改为:
return File(fileStream, "application/pdf", "MyRenamedFile.pdf");