我有一个带有一个pdf文件的“Gallery”文件夹
我使用对象查看pdf文件,然后我需要通过单击“单击此处下载pdf文件”链接下载该pdf文件
请帮我,
我使用一个对象查看pdf文件,之后我点击“点击此处下载pdf文件”,当我点击该链接时我想下载pdf
这是我到目前为止的代码:
public ActionResult downloadpdf()
{
using (var client = new WebClient())
{
var buffer = client.DownloadData("~/Gallery/NewsBulletin.pdf");
return File(buffer, "application/pdf", "mypdffile.pdf");
}
}
public ActionResult DownloadPdf()
{
return File("mypdffile.pdf", "application/pdf",
Server.MapPath("~/Gallery/NewsBulletin.pdf"));
}
如果文件不在站点目录中,您仍然可以在控制器操作中指定完整路径,即
public ActionResult DownloadPdf()
{
return File("mypdffile.pdf", "application/pdf",
"C:\\VerySecretFile.pdf");
}