我一直在尝试将以字节数组形式存储在数据库中的文件转换为网站上的可下载文件。下载链接似乎会产生一行重复的乱码。
我的文档已作为此类存储在数据库中
public class User
{
public string ResumeName { get; set; }
public byte[] Resume { get; set; }
public string ResumeContentType { get; set; }
}
为了将信息作为文档检索回来,我使用这个函数
public IActionResult Download(byte[] filebytes, string type, string name)
{
return File(filebytes, type, name);
}
网页本身使用此操作链接来生成创建下载链接的按钮
@Html.ActionLink("Download File", "Download", new {
filebytes = @UserManager.GetUserAsync(User).Result.Resume,
type = @UserManager.GetUserAsync(User).Result.ResumeContentType,
name = @UserManager.GetUserAsync(User).Result.ResumeName
})
运行代码时,单击链接不会执行任何可见操作,这意味着我无法看到它是如何出错的。然而,在新选项卡中打开链接会产生这个已大大缩短的长链接
https://localhost:7095/Home/Download?filebytes=80&filebytes=75&......(this repeated several hundred times)...... filebytes=0&filebytes=0&filebytes=0&filebytes=0&type=application%2Fvnd.openxmlformatsofficedocument.wordprocessingml.document&name=__xid-43512761_1.docx
为什么会发生这种情况?有办法解决吗?