簡體   English   中英

從Asp.Net Mvc中的數據庫下載文件

[英]Downloading files from the database in Asp.Net Mvc

我將我的文件存儲在數據庫中,需要在單擊按鈕時下載文件。
我可以在動作方法中獲取文件內容(二進制)。 但是如何將其作為文件返回給用戶?

<%= Html.ActionLink("download file", "download") %>

在你的行動中:

public ActionResult Download() 
{
    byte[] contents = GetFileContentsFromDatabase();
    return File(contents, "image/jpeg")
}
return new FileContentResult(byte[], contentType)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM