【发布时间】:2018-07-14 22:48:17
【问题描述】:
我的下载方式是
public async Task<IActionResult> Download(string filename)
{
if (filename == null)
return Content("filename not present");
var path = Path.Combine(
Directory.GetCurrentDirectory(), "wwwroot" + @"\UploadFiles", filename);
var memory = new MemoryStream();
using (var stream = new FileStream(path, FileMode.Open))
{
await stream.CopyToAsync(memory);
}
memory.Position = 0;
return File(memory, GetContentType(path), Path.GetFileName(path));
}
和 view.chtml 和带有文件路径的路由
<a asp-action="Download"
asp-route-filename="@item.UploadFilePath">
Download
</a>
@item.UploadFilePath 是数据库保存的路径。请帮助我。
【问题讨论】:
-
为什么要标记
javascriptjquery? -
那你有什么问题?
标签: asp.net-mvc asp.net-core-1.1