Solved

Strange Error with PDF and Download Redirect Script

Posted on 2007-04-04
4
302 Views
Last Modified: 2013-11-19
Hi,

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.Clear();
Response.Buffer = true;
Response.Expires = 0;
Response.AddHeader("Content-Disposition", strDisposition + " ;filename=" + Server.UrlEncode(strFileName + "." + strFileExt));
Response.ContentType = strMimeType;
Response.WriteFile(objFile.FullName);
Response.Flush();
Response.End();

Where:
- 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?
0
Comment
Question by:SiraX
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Author Comment

by:SiraX
ID: 18848968
Here are some more information related to the problem - (not) working combinations:
IE: Internet Explorer, AR: Acrobat Reader, AP: Acrobat Professional
1. Windows XP (corp network), IE6, AP7 -> not working
2. Windows XP (corp network), IE6, AR7 -> not working
3. Windows XP (corp network), IE6, AR7 -> not working
4. Server 2003 Std, IE7 (corp network), AR5 -> working
5. Windows XP (corp network), IE7, AR8 -> working
6. Windows Vista (home), IE7, AR8 -> working

And as already said, with Firefox it is working all the time ...

Another hint, I found right now in forums and newsgroups (actually PHP related) that IE6 with Acrobat seems to have problems with the cache ... and I have implemented an OutputCache in my download redirect script. Can someone confirm this as the error?
0
 
LVL 19

Accepted Solution

by:
DreamMaster earned 500 total points
ID: 18848991
Things I have found could cause similar problems:

- Acrobat Reader was installed but for some reason the web part of it doesn't work properly. It can never open a document in the browser in other words..

- Caching will sometimes destroy your ability to open a pdf file in the browser, like you said it is a known problem, but one that is hard to reproduce

Hope it helps.
Regards,
Max.
0
 

Author Comment

by:SiraX
ID: 18849046
Hi there,
Ok, I found the problem now ... I could reproduce the problem on a testing machine with IE6, after upgrading to IE7 it worked fine.

The problem was indeed the OutputCache in combination with Internet Explorer 6! So if other people have the same problem, think about removing caching options.

Best regards,
David
0
 
LVL 19

Expert Comment

by:DreamMaster
ID: 18849079
Glad to have been helpful :)

Regards,
Max.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question