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
C# 将新创建的pdf显示到其他选项卡_C#_Asp.net Mvc - Fatal编程技术网

C# 将新创建的pdf显示到其他选项卡

C# 将新创建的pdf显示到其他选项卡,c#,asp.net-mvc,C#,Asp.net Mvc,这就是我要做的。当我点击超链接时,它会打开一个新标签,然后显示我新创建的pdf。但我的代码一直在当前选项卡上显示它 查看代码 @Html.ActionLink("User", "PRintPDF", new { target = "_blank" }) 和控制器 Response.ContentType = "application/pdf"; Response.AddHeader("content-length", renderedBytes.Length.ToString(

这就是我要做的。当我点击超链接时,它会打开一个新标签,然后显示我新创建的pdf。但我的代码一直在当前选项卡上显示它

查看代码

@Html.ActionLink("User", "PRintPDF", new { target = "_blank" })
和控制器

    Response.ContentType = "application/pdf";
    Response.AddHeader("content-length", renderedBytes.Length.ToString());
    Response.AddHeader("Content-Disposition", "inline;filename=somefile.pdf");
    Response.BinaryWrite(renderedBytes); 
    Response.Flush();
试试你的观点

@Html.ActionLink("User", "PRintPDF", new {id = 1}, new {@target="_blank"})

actionlink应该有4个html属性参数。

这应该适用于大多数浏览器。你用的是什么操作系统和浏览器?我也是这么想的。我的操作系统使用FF版本39.0和windows 7。