Strange Error with PDF and Download Redirect Script
Posted on 2007-04-04
I've got some trouble on my download redirect script. On some places it works fine but on other workstations I get an error.
Ok, here is what the script does (C#):
Response.Buffer = true;
Response.Expires = 0;
Response.AddHeader("Content-Disposition", strDisposition + " ;filename=" + Server.UrlEncode(strFileName + "." + strFileExt));
Response.ContentType = strMimeType;
- strDisposition is either "inline" or "attachment", but in the case of my PDF files it is "attachment" to force the user to download the file instead of opening the PDF with the Browser Plug-In.
- strFileName is the filename with all special characters removed and strFileExt is the extension of the file (.pdf)
- strMimeType is the ContentType of the document, in my problem case: "application/pdf"
- objFile.FullName is the full absolut physical path on the server (which has the right permissions to be accessed)
Well as I already mentioned, on some workstation it works, I don't think it is an Acrobat problem (it is working with Acrobat 7 and 8), it is working on some workstations with IE6 and IE7. But actually in Firefox it is working all the time (no problems). The file is being downloaded, but when we open it with the default application (Acrobat) we get an error telling us that there has been an error while opening the document, the file could not be found.
A workaround is to save the file to the desktop (or somewhere else) and then opening it with a double click.
I really can't figure out where the problem is ... does anybody has a clue?