2011-08-15 40 views

回答

0

你可以設計一個控制器動作將從數據庫中讀取PDF路徑和它傳輸到響應:

public ActionResult ShowPdf() 
{ 
    string path = ... fetch path from database 
    if (!System.IO.File.Exists(path)) 
    { 
     // the file was not found 
     throw new HttpException(404, "Not found"); 
    } 
    return File(path, "application/pdf", "test.pdf"); 
} 

,然後你可以創建一個鏈接,這個動作在你看來:

<%= Html.ActionLink("download pdf", "showpdf", "somecontroller") %> 
+0

thankx很多,這允許下載PDF,但希望在我的navigateur – fatma

+0

@fatma顯示PDF,以確保數據庫中存在的文件路徑必須是相對路徑而不是物理路徑,並將該路徑分配給'你的鏈接的href' –

相關問題