我将文件存储在数据库中,需要在单击按钮时下载文件。
我可以在操作方法中获取文件内容(二进制)。但是如何将其作为文件返回给用户呢?
最佳答案
<%= Html.ActionLink("download file", "download") %>
在你的行动中:
public ActionResult Download()
{
byte[] contents = GetFileContentsFromDatabase();
return File(contents, "image/jpeg")
}
关于c# - 从 Asp.Net Mvc 中的数据库下载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2433860/