开发者

Downloading files from the database in Asp.Net Mvc

开发者 https://www.devze.com 2022-12-22 14:56 出处:网络
I\'m storing my files in the datab开发者_Python百科ase and need to download a file when button clicked.

I'm storing my files in the datab开发者_Python百科ase and need to download a file when button clicked.

i can get the File content (Binary) in the action method. But how to return it as a file to the user?


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

and in your action:

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


return new FileContentResult(byte[], contentType)
0

精彩评论

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

关注公众号