Monday, June 25, 2018

DOWNLOAD UPLOADED FILE IN ASP.NET MVC

 @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

javascript Filter/index off

 var family = [{"name":"Jack",  "age": 26},               {"name":"Jill",  "age"...