保存MVC文件对话框 [英] Save file dialog in MVC

查看:108
本文介绍了保存MVC文件对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建保存文件对话框中的MVC应用程序?
我找不到任何的例子。

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

在此先感谢。

推荐答案

通过返回文件时使用内容处置头附件下载:

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

这篇关于保存MVC文件对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆