【发布时间】:2014-10-20 15:33:38
【问题描述】:
我在远程 Web 服务器上的以下位置有一个 PDF 文档:
C:\Domains\Bin\Invoices\1000.pdf
如何链接它?我试过了:
string rootPath = Server.MapPath("~");
string path = Path.GetFullPath(Path.Combine(rootPath, "..\\Bin\\Invoices"));
<p>@Html.Raw("<a href='"+ path + "\\" + "1000.pdf'>Original PDF copy</a>")</p>
没有成功:浏览器工具提示显示file:///C:/domains/bin/invoices/1000.pdf
谢谢。
编辑
使用乔建议解决,这样:
public FileResult InvoiceInPdf(string id)
{
string rootPath = Server.MapPath("~");
string path = Path.GetFullPath(Path.Combine(rootPath, "..\\Bin\\Invoices\\"));
return File(path + id + ".pdf", "application/pdf");
}
【问题讨论】:
标签: asp.net asp.net-mvc url