Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 3 在mvc中使用FilePathResult将filestream返回到UI_Asp.net Mvc 3 - Fatal编程技术网

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()