我有一个将pdf文件写入aspx页面的代码,但问题是当我想保存这个文件时,它会用aspx扩展名保存.例如:
它保存为myPDFfile.aspx,而我想将它保存为myPDFfile.pdf
我必须将扩展更改为.pdf才能打开它。
如何以编程方式更改扩展?
我的代码:
Dim pdfPath As String = path + Session("factura").ToString.Trim + ".pdf"
Dim client As New WebClient()
Dim buffer As [Byte]() = client.DownloadData(pdfPath)
Response.ContentType = "application/pdf"
Response.AddHeader("content-length", buffer.Length.ToString())
Response.BinaryWrite(buffer)发布于 2013-06-24 14:37:34
您需要添加一个带有文件名的content-disposition头。
Response.AddHeader("content-disposition", "attachment; filename=myPDFfile.pdf");这是RFC 2616第19节的一部分。
https://stackoverflow.com/questions/17278085
复制相似问题