目前大多瀏覽器都有內建Adobe Reader,可以直接在網頁上瀏覽
如果想讓使用者下載PDF的話只要使用WebClient類別
即使有裝Reader也會跳出下載提示了!
測試過手機瀏覽器也能正常下載
System.Net.WebClient wb = new System.Net.WebClient();
//檔案路徑
string link = "http://localhost:56303/TempWebsite/Areas/DownloadPDF/Test.pdf";
Response.ClearHeaders();
Response.Clear();
Response.Expires = 0;
Response.Buffer = true;
Response.AddHeader("Accept-Language", "zh-tw");
Response.AddHeader("Content-Disposition", "Attachment;FileName=" + System.Web.HttpUtility.UrlEncode("測試PDF.pdf", System.Text.Encoding.UTF8));
Response.ContentType = "Application/pdf";
Response.BinaryWrite(wb.DownloadData(link));
Response.End();