@Html.ActionLink(" ", "Download", "Home",
new { fileId = Id, filename = Model.FileName},
new { @class = "downloadFile" })
OR
<a href="@Url.Action("DownloadFile", "Home", new { studentId = 123 })">Download Form</a>
===============================================================
public FileResult DownloadFile(long fileId, string filename)
{
var filepath = Path.Combine(GetFilePath(fileId)); //fetch from database
var fileData = System.IO.File.ReadAllBytes(filepath);
return File(fileData, System.Net.Mime.MediaTypeNames.Application.Octet, filename);
}
No comments:
Post a Comment