My scenario is that a user requests a file from a webpage, the page authenticates them and verifies their security level, then gives them the requested file. For some reason this works with every filetype except PDFs (zips, csv, xls... all good).
Can anyone identify what I am doing wrong?
[tt]
fs = File.Open(strPath & "\" & strFileName, FileMode.Open)
dim bytBytes(fs.Length) as Byte
fs.Read(bytBytes, 0, fs.Length)
fs.Close
with Response
.Clear()
.AddHeader("content-disposition", "inline; filename=" & strFilename)
.ContentType = strContentType
.Write(strContentType)
.BinaryWrite(bytBytes)
.End()
End With
[/tt]
I can save PDFs to file by right-clicking, but cannot view them in the browser. I did place a PDF on the file-system, to make sure Adobe isn't broken, and it displayed without a problem.
Could it have something to do with the way I am reading the file?
Can anyone identify what I am doing wrong?
[tt]
fs = File.Open(strPath & "\" & strFileName, FileMode.Open)
dim bytBytes(fs.Length) as Byte
fs.Read(bytBytes, 0, fs.Length)
fs.Close
with Response
.Clear()
.AddHeader("content-disposition", "inline; filename=" & strFilename)
.ContentType = strContentType
.Write(strContentType)
.BinaryWrite(bytBytes)
.End()
End With
[/tt]
I can save PDFs to file by right-clicking, but cannot view them in the browser. I did place a PDF on the file-system, to make sure Adobe isn't broken, and it displayed without a problem.
Could it have something to do with the way I am reading the file?