2015-04-27 28 views
-2

我將pdf以二進制形式存儲在數據庫中。我想要點擊時顯示它們的鏈接。我首先使用了entity-framework code-mvc和c#。如果有人知道它是如何工作的,請告訴我。 謝謝。鏈接顯示存儲在數據庫中的pdf

+0

能否請您分享一下你做了這麼遠嗎?任何錯誤? – ramiramilu

回答

0

你需要創建一個在您的任何控制器中執行任何操作,可以從數據庫中選擇二進制編碼的pdf並根據請求提供。例如:

class PDFController : Controller 
{ 
    public ActionResult Download(int id) 
    { 
    byte[] fileContents; 
    // Your code to read the binary file from DB. 
    // fileContents = // Populate from DB 

    return new FileContentResult(fileContents, "application/pdf"); 
    } 

} 

現在添加一個鏈接到這個動作說(/pdf/download/1

相關問題