我想传递一个文件夹路径使用@Html.ActionLink
一个下载器,但我越来越找不到像如何通过一个文件夹路径MVC控制器
找不到文件“C的位置误差:\ Teerth 内容\项目\ Colege \ Web应用程序\媒体\ @ item.Content”
然而,当我给硬编码值,它的工作。我可以提出一些建议吗?
这里是我的代码: 操作方法:
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);
}
视图
@Html.ActionLink("Download", "Download", "Marketing", routeValues: new
{
fileName = @item.Content,
filePath = Server.MapPath("~/Media/@item.Content"),
area = "AffiliateAdmin"
}, htmlAttributes: null)
'filePath = Server.MapPath(“〜/ Media /”+ @ item.Content)' –
谢谢你发现问题。 – Teerth