【发布时间】:2014-01-29 15:40:54
【问题描述】:
我正在使用 RazorPDF,我想强制下载 PDF,而不是在浏览器选项卡中打开。我该怎么做呢?谢谢
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(string Id)
{
return RedirectToAction("Pdf");
}
public PdfResult Pdf()
{
// With no Model and default view name. Pdf is always the default view name
return new PdfResult();
}
【问题讨论】:
-
您需要在响应头中设置
content-disposition- stackoverflow.com/questions/1012437/…。 -
如何在上面的代码中做到这一点?
-
我没有使用过 RazorPDF,但您可以在返回 PDF 文件之前在您的操作中添加链接答案中的代码。
标签: c# asp.net asp.net-mvc asp.net-mvc-4 razorpdf