I am trying to pass a folder path to a download controller using @Html.ActionLink
, but I am getting could not find the location error like
Could not find file 'C:\Teerth Content\Project\Colege\WebApp\Media\@item.Content'
However when I give the hard coded value it does work. May I have suggestions what is wrong with that.
Here is my code: Action method:
public FileResult Download(string fileName, string filePath)
{
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
string documentName = fileName;
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, documentName);
}
view
@Html.ActionLink("Download", "Download", "Marketing", routeValues: new
{
fileName = @item.Content,
filePath = Server.MapPath("~/Media/@item.Content"),
area = "AffiliateAdmin"
}, htmlAttributes: null)