2011-07-25 67 views

回答

4

通过返回文件时使用Content-Disposition头附件下载:

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"); 
} 
+0

想你错过的东西有... – Dismissile

+0

@Dismissile,什么? –

+0

您的退货声明是否正确?你不需要调用一个方法吗? – Dismissile