Asp.net mvc 3 在mvc中使用FilePathResult将filestream返回到UI
我在控制器中有一个动作Asp.net mvc 3 在mvc中使用FilePathResult将filestream返回到UI,asp.net-mvc-3,Asp.net Mvc 3,我在控制器中有一个动作 public ActionResult Download() { return File(FileStream, "application/octet-stream", fileName); } public FilePathResult Download() 如果我想使用FilePathresult作为: public FilePathResult Download() { return File(FileStream, "applic
public ActionResult Download()
{
return File(FileStream, "application/octet-stream", fileName);
}
public FilePathResult Download()
如果我想使用FilePathresult作为:
public FilePathResult Download()
{
return File(FileStream, "application/octet-stream", fileName);
}
public FilePathResult Download()
我可以点击下面的按钮调用Download()
@Html.ActionLink("FileDownload", "Download", new { file = item.FileName, GuID = item.DocumentGuID }) /text).Width(10);
public FilePathResult Download()
另外,Download()
的实现在第二个实例中是正确的,即
public FilePathResult Download()
?您的
ActionLink
定义了要传递的参数,因此您需要将这些参数添加到操作中
public FilePathResult Download()
@Html.ActionLink("FileDownload", "Download", new { file = item.FileName, GuID = item.DocumentGuID }) /text).Width(10);
我不确定什么是/text.Width(10)
正在执行此操作,但是具有参数的正确格式的ActionLink
也必须将Html属性定义为最后一个参数,只需传入null
public FilePathResult Download()
下面是一个格式正确的ActionLink
示例
public FilePathResult Download()
@Html.ActionLink("ActionName", "ControllerName", new { id = 10}, null)
链接中有一个文件
和一个GuID
参数,因此将它们作为参数添加到操作中
public FilePathResult Download()
public FilePathResult Download(string file, Guid GuID)
{
return File(FileStream, "application/octet-stream", fileName);
}
试试看,让我们知道会发生什么:-)
public FilePathResult Download()
快乐编码 你为什么不亲自去看看呢?如果你已经做了,问题是什么?
public FilePathResult Download()