0
我想返回一個PDF文件作爲對按鈕點擊的響應。 我成功發送pdf文件,但是當我試着通過瀏覽器保存它,它不會讓我將它保存爲.pdf文件(但.aspx文件)ASP.NET如何在不改變響應頭的情況下返回PDF文件作爲響應
下面的代碼:
Dim myWebClient As WebClient = New WebClient()
Dim myDataBuffer As Byte() = myWebClient.DownloadData(LocalImageURL) ' LocalImageURL is some path to a pdf file
Response.ContentType = "application/pdf"
esponse.BinaryWrite(myDataBuffer)
Response.Flush()
Response.End()
如果我還添加以下行寫入字節數組前:
Response.AddHeader("content-disposition", "attachment;filename=report.pdf")
它的伎倆,但問題是,頁面仍然停留(看起來像它仍在等待服務器響應來)
你沒有。它可以是PDF或網頁,而不是兩者。 – VDWWD