Question about showing PDF file

  • Thread starter Thread starter Green
  • Start date Start date
G

Green

Hi,
I have an urgent question about showing the PDF. I got the following
message:

Some files can harm your computer. If the file information below looks
suscipcious, or you do not fully trust the source, do not open or save this
file.
File name: XXX.pdf
....
Then i click open, i have error message again like below:
Internet Explorer cannot download XXX.pdf from ....

I can successfully run from the local machine, but from the application
machine i got above error message. The codes are exactly the same between
local machine and the application machine.

Really appreciate your help.
THX.
 
Some files can harm your computer. If the file information below looks
suscipcious, or you do not fully trust the source, do not open or save this
file.
File name: XXX.pdf

2 thoughts:

1) Is your security on your browser set to some paranoid level?

2) Is maybe the live site sending a different mime type than your local
machine for PDF files?

-Darrel
 
Hi Green,

In addition to Darrel's suggestions, I think you can also check the
following things:
1. Is it ok to save the pdf , if we don't chose"open", but save it to
client disk?

2. The problem only occurs when you deploy the web application on that
application server? Will the problem reoccur if we visit that page from
some othe client machines?

3. AS Darrel has mentioned the live site's mime setting, I think you can
also compare the other settings between your local site and the applicaiotn
server's iis site setting. Maybe there're some thing different which may
cause the problem.

Thanks.

Regards,

Steven Cheng
Microsoft Online Support
 
Have had the same problem months ago. Believe it has something to do with the
way you pass the pdf to the browser. Maybe an open door, but try the
following code:

// Create new reference to the report
Reports.myrep crReportDocument = new Reports.myrep();

//To PDF
System.IO.MemoryStream ReportStream =

(System.IO.MemoryStream)crReportDocument.ExportToStream( ExportFormatType.PortableDocFormat);
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.BinaryWrite(ReportStream.ToArray());
Response.End();
 
I came across a possible cause/resolution while researching a similar problem
with PDF documents. There is a documented problem using things like Excel or
Word with documents on the client. It also seems to affect PDF's. If the
virtual directory on an IIS server has "expire immediately" turned on for the
location of the PDF then a similar error will occur. A solution was to locate
the PDF in a directory in which the content expiration was something other
than "immediately".
 
Back
Top