Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.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 ASP.NET MVC在新窗口中打开文件_Asp.net Mvc_Asp.net Mvc 4_Web - Fatal编程技术网

Asp.net mvc ASP.NET MVC在新窗口中打开文件

Asp.net mvc ASP.NET MVC在新窗口中打开文件,asp.net-mvc,asp.net-mvc-4,web,Asp.net Mvc,Asp.net Mvc 4,Web,我创建了一个MVC Web应用程序。 当用户单击页面上的“查看”按钮时,我需要打开pdf文件。 存储pdf的文件路径是从数据库读取的,它是c上的一个文件:如何在代码中打开它 我有以下代码: @Html.ActionLink("Read", "ViewOnline", new { controller = "Home", id = item.Id }, new { target = "_blank" }, new { @class = "btn btn-default" }) 还有我的控制器 p

我创建了一个MVC Web应用程序。 当用户单击页面上的“查看”按钮时,我需要打开pdf文件。 存储pdf的文件路径是从数据库读取的,它是c上的一个文件:如何在代码中打开它

我有以下代码:

@Html.ActionLink("Read", "ViewOnline", new { controller = "Home", id = item.Id }, new { target = "_blank" }, new { @class = "btn btn-default" })
还有我的控制器

public ActionResult ViewOnline(int id)
{
  string link = BookBUS.Instance.GetBooks().Find(x => x.BookID == id).FilePath;
  if (link != null)
  {
    TempData["Embed"] = VirtualPathUtility.ToAbsolute(link);
  }
}

您正在为HTML属性创建两个单独的对象:

new { target = "_blank" }, new { @class = "btn btn-default" }
new { target = "_blank", @class = "btn btn-default" }
我甚至不确定
ActionLink
方法会调用什么重载。但有一点是肯定的,这两个单独的方法参数不会在HTML属性内部组合

为HTML属性创建一个对象:

new { target = "_blank" }, new { @class = "btn btn-default" }
new { target = "_blank", @class = "btn btn-default" }
然后应该使用。

错误“字符文字中的字符太多”