I'm storing my files in the database 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?
views:
52answers:
2or just `return File(...)`
Seth Petry-Johnson
2010-03-12 15:51:45
+4
A:
<%= Html.ActionLink("download file", "download") %>
and in your action:
public ActionResult Download()
{
byte[] contents = GetFileContentsFromDatabase();
return File(contents, "image/jpeg")
}
Darin Dimitrov
2010-03-12 15:51:18