开发者

Save file dialog in MVC

How to create save file dialog in MVC application? I couldn't find any example.

Thanks in开发者_运维知识库 advance.


By using the Content-Disposition header to attachment when returning the file to download:

public ActionResult Download()
{
    return File(@"c:\work\report.pdf", "application/pdf", "reoprt.pdf");
}

Or if the file to download is dynamically generated:

public ActionResult Download()
{
    byte[] pdf = ... get the contents of the report
    return File(pdf, "application/pdf", "reoprt.pdf");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜