1

Okay so I am having some trouble finding an answer for this through google.

I am trying to setup a site using c# that will display an embedded PDF on the page using dynamic file names. Here is my code:

aspx: < iframe style="vertical-align:auto" name="pdfIframe" id="pdfIframe" width="1024px" height="1200px" runat =server></iframe >

cs: pdfIframe.Attributes["src"] = @"" + fullfilepath;

"fullfilepath" is a string that contains the file path for the pdf I want to open. The problem I'm running into is that the PDF is opening fine when I run the debugger but once I publish the site and navigate to it from another PC it opens the pdf in Adobe Reader and not the iframe regardless of what browser I am using. Am I missing something here?

Kara
  • 6,115
  • 16
  • 50
  • 57
Matt P
  • 618
  • 2
  • 12
  • 20
  • (The string literal isn't really needed as there are no characters that need to be escaped - that includes the data within fullfilepath.) Did you use the solution from this post? http://stackoverflow.com/questions/11646665/open-pdf-in-web-page-of-asp-net – TekuConcept Dec 19 '13 at 18:49
  • No I didn't get my answer there. I took the literal out and it is still doing the same thing. – Matt P Dec 19 '13 at 18:55
  • I should add that when I launch the same app in Chrome it doesn't open the PDF in the iframe or Adobe, it just doesn't launch. – Matt P Dec 19 '13 at 18:59
  • What is the string value of fullfilepath? – TekuConcept Dec 19 '13 at 19:09
  • I put that code into my project and it tried to save the pdf to my local machine. – Matt P Dec 19 '13 at 19:17
  • Sorry, but again, what is the value of fullfilepath? – TekuConcept Dec 19 '13 at 19:22
  • Full filepath is the value of some text and two other strings put together, looks something like this: `serverinfo = @"\\servername\e$\folder\folder";` `pdfname = "MAC" + account + "." + procid + ".pdf";` `fullfilepath = serverinfo + pdfname;` – Matt P Dec 19 '13 at 19:23
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/43541/discussion-between-christopher-walker-and-matt-p) – TekuConcept Dec 19 '13 at 19:24

1 Answers1

0

So my problem was that the file path I was using @"\servername\e$\folder\folder" needed to be shared out and changed to "\servername\folder\folder". It's funny how two characters can screw up your whole project and steal two hours of your day!

Matt P
  • 618
  • 2
  • 12
  • 20