gpt4 book ai didi

C#MVC : Chrome using the action name to set inline PDF title

转载 作者:太空狗 更新时间:2023-10-29 19:45:08 24 4
gpt4 key购买 nike

我有一个在新浏览器选项卡中显示 PDF 的操作。

    public ActionResult Print()
{
var cd = new ContentDisposition
{
FileName ="something.pdf",
Inline = true
};
Response.AppendHeader("Content-Disposition", cd.ToString());
return File(reportResponse.Data.Document, MediaTypeNames.Application.Pdf);

}

文件名工作正常。当我下载文件时,它的名称是我想要的“something.pdf”。

问题是当 google chrome 在新的浏览器选项卡中打开 PDF 时,它会将 Controller 操作名称(打印)显示为 PDF 的标题。这就是我想要改变的。我附上一张照片以作澄清。 enter image description here

查看代码:Url.Action("Print", "Controller", new { area = "Area"}), new { @target = "_blank"}

最佳答案

给action方法传递文件名参数,确保参数名是'id'

查看代码:

Url.Action("Print", "Controller", new { id = "filename", area = "Area"}), new { @target = "_blank"}

关于C#MVC : Chrome using the action name to set inline PDF title,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34890641/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com