如何在 MVC 应用程序中创建保存文件对话框? 我找不到任何例子。
提前致谢。
最佳答案
返回要下载的文件时,使用附件的 Content-Disposition
header :
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");
}
关于asp.net-mvc - MVC 中的保存文件对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6816727/