如何在MVC应用程序中创建保存文件对话框?
我找不到任何示例。
提前致谢。
提前致谢。
通过在下载文件时使用Content-Disposition
头部设置为attachment:
public ActionResult Download()
{
return File(@"c:\work\report.pdf", "application/pdf", "reoprt.pdf");
}
或者,如果要下载的文件是动态生成的:
public ActionResult Download()
{
byte[] pdf = ... get the contents of the report
return File(pdf, "application/pdf", "reoprt.pdf");
}
public FileResult Download()
才能使其工作。这可能是由于自2011年以来Web浏览器安全性的更改所致。 - JabberwockyDecompiler