0
我已經從數據庫中檢索到pdf文件並將其鏈接到「a href」標籤以使用鏈接打開pdf文件。現在我想在打開pdf文件之前給出打開/保存對話框。 - 在JavaScript(通過使用的onclick事件中的「一」的標籤,以調用JavaScript)在asp.net中從DB-檢索pdf文件的鏈接
我已經從數據庫中檢索到pdf文件並將其鏈接到「a href」標籤以使用鏈接打開pdf文件。現在我想在打開pdf文件之前給出打開/保存對話框。 - 在JavaScript(通過使用的onclick事件中的「一」的標籤,以調用JavaScript)在asp.net中從DB-檢索pdf文件的鏈接
你必須設置使用C#來獲得在瀏覽器這種行爲內容處置頭。
閱讀更多信息
How do I prompt a "Save As" dialog for an accepted mime type?
Downloading a File with a Save As Dialog in ASP.NET
例
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.AddHeader("Content-Length", targetFile.Length.ToString);
Response.ContentType = "application/pdf";
Response.WriteFile(targetFile.FullName);
+1,這裏的另一個相關的SO職位:http://stackoverflow.com /問題/ 1024910 /允許用戶對下載從-M Y形通響應,WriteFile的 – 2009-11-28 05:44:30