Cannot open PDF files

Is this a setting in IIS?

Page 1 of 1

6 Replies - 12317 Views - Last Post: 10 September 2009 - 11:47 AM Rate Topic: -----

#1 awwyeh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 15-February 09

Cannot open PDF files

Posted 20 March 2009 - 12:04 PM

I am developing an ASP.NET VB web application which includes links to our product documentation. 99% of the documentation is in PDF format, but I am experiencing the same problem for other file types as well.

Basically I click on the link, which I know is valid, and the browser can't find the file. In this example, I do have .PDF as a MIME type 'application/pdf' (I've tried 'application/octet-stream as well). This is happening for every file type I'm testing (PDF, DOC, PPS, XLS, etc.)

Has anyone experienced this or know of a resource that might help? Is this IIS? Web.config? Permissions?

Thanks for your help.

John

Is This A Good Question/Topic? 0
  • +

Replies To: Cannot open PDF files

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Cannot open PDF files

Posted 20 March 2009 - 01:33 PM

Nope, no settings in IIS to worry about.

Would I be correct in assuming that you are opening the PDF in a browser window?

If so, then post the code showing how you are doing it. More than likely the problem is with your implementation.

But just to give you an idea of how I do it at work. First I convert the PDF to a byte array, then I open a pop-up window. From within that window I take the byte array and give it to the Response.BinaryWrite method to generate the PDF on the clients computer.

Example:
byte[] zz = null;

zz = pdfs.GetPolicyDocumentsMemory(ref appInfo, sortedList, sess, Request.PhysicalApplicationPath);

Response.Buffer = true;
Response.Expires = 0;
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Type", "application/pdf");
Response.AddHeader("Content-Disposition", "inline;filename=Example.pdf");

this.Response.BinaryWrite(zz);
this.Response.End();


Was This Post Helpful? 1
  • +
  • -

#3 almogaver  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 20-March 09

Re: Cannot open PDF files

Posted 20 March 2009 - 05:11 PM

Hi,

Are you sure that the path is correct? Take a look at your IIS log files and try to find the 404 errors. In those log lines there should be the path you are requesting. Then compare it with the suposed path.
Another matter could be permissions on file system. If you copied, moved (whatever) files using Windows Explorer those files could get your user permissions and the account under IIS runs has no rights over them. To give it a try set Every one to full control and see if this works. If you succeed then adjust permissions as your environment needs (specially if this is a production IIS faced to the world).

Good luck!
Was This Post Helpful? 0
  • +
  • -

#4 kansascoder  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 9
  • Joined: 22-March 09

Re: Cannot open PDF files

Posted 22 March 2009 - 07:44 AM

Is there a public url that you could post for us?
Personally, I've never had to set special permissions to open a pdf in a directory that is in my application's main folder.
On my local/developer machine the 'Users' group has read&execute, list folder contents, read and special permissions checked to allow.
This is an intranet application so perhaps those settings aren't safe for a public internet.
Was This Post Helpful? 0
  • +
  • -

#5 awwyeh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 15-February 09

Re: Cannot open PDF files

Posted 23 March 2009 - 06:07 AM

View PostJayman, on 20 Mar, 2009 - 12:33 PM, said:

Nope, no settings in IIS to worry about.

Would I be correct in assuming that you are opening the PDF in a browser window?

If so, then post the code showing how you are doing it. More than likely the problem is with your implementation.

But just to give you an idea of how I do it at work. First I convert the PDF to a byte array, then I open a pop-up window. From within that window I take the byte array and give it to the Response.BinaryWrite method to generate the PDF on the clients computer.

Example:
byte[] zz = null;

zz = pdfs.GetPolicyDocumentsMemory(ref appInfo, sortedList, sess, Request.PhysicalApplicationPath);

Response.Buffer = true;
Response.Expires = 0;
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Type", "application/pdf");
Response.AddHeader("Content-Disposition", "inline;filename=Example.pdf");

this.Response.BinaryWrite(zz);
this.Response.End();



Jayman, almogaver, kansascoder - thank you for your willingness to help me out with this. I've never had a problem with linking to a PDF file, so this is very strange. Let me explain what I'm doing.

Basically I'm using a DataList to display records in an MS SQL database - nothing fancy. I should add I'm doing it in VB as well.

Each result shows the name of the PDF surrounded by a hyperlink to that PDF document. When a user clicks the link, the PDF should load in the browser window. The code is below:

<asp:DataList ID="DataList1" runat="server" 
			 DataSourceID="SqlDataSourceReleaseNotes">
			 <ItemTemplate>
				 <div id="contentdisplay">
				 <a href="../Data/Products/PathLinks/<%# Eval("fileName") %>" target="_blank"><asp:Label ID="fileDescLabel" runat="server" Text='<%# Eval("fileDesc") %>' /></a> - <asp:Label ID="fileTypeLabel" runat="server" Text='<%# Eval("fileType") %>' CssClass="small" />
				 <br />
				 <asp:Label ID="fileNotesLabel" runat="server" Text='<%# Eval("fileNotes") %>'/>
				 </div>
			 </ItemTemplate>
		 </asp:DataList>


Another note regarding this problem - I don't think it's exclusive to this DataList or resulting syntax. During my troubleshooting, I created a blank .aspx page, named it 'test.aspx' and placed it in the root directory. Then I uploaded a random PDF file in the same root directory and attempted to link to it using a regular <a href> tag and it didn't work. Neither IE nor Firefox can see these files.
Was This Post Helpful? 0
  • +
  • -

#6 awwyeh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 15-February 09

Re: Cannot open PDF files

Posted 23 March 2009 - 07:01 AM

View Postkansascoder, on 22 Mar, 2009 - 06:44 AM, said:

Is there a public url that you could post for us?
Personally, I've never had to set special permissions to open a pdf in a directory that is in my application's main folder.
On my local/developer machine the 'Users' group has read&execute, list folder contents, read and special permissions checked to allow.
This is an intranet application so perhaps those settings aren't safe for a public internet.


I FOUND THE PROBLEM!!

I dug around a little bit more in IIS and found that the .PDF extension was listed in the Application Configuration dialog box with ALL verbs. I removed the .PDF extension from this list (I'm not sure how it got there and was not listed in other websites I've administered in the past) and now the documents open in the browser as intended.

Thanks for all of your help and suggestions. Great community!
Was This Post Helpful? 0
  • +
  • -

#7 Demina  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 10-September 09

Re: Cannot open PDF files

Posted 10 September 2009 - 11:47 AM

Hello
I have the same problem that Jonh, I can not see Pdf files from a web application.
I removed the .pdf extension of the MIME types but the problem continues.

Im not sure where are the "Application Configuration dialog box"
can you help me?

Thank you
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1