Loading a pdf file into iframe.

C

Control Freq

Hi,
Confused about loading a pdf file into an iframe from C# code behind.

I have a PDF file called temp2.pdf in my document root. The file is
physically located at C:\inetpub\wwwroot\MySite\temp2.pdf .

In the code behind I try:

Iframe1.Attributes.Add("src", "\\MySite\\temp2.pdf"); // THIS WORKS
Iframe1.Attributes.Add("src",
"c:\\inetpub\\wwwroot\\MySite\\temp2.pdf"); // NOT WORK.
Iframe1.Attributes.Add("src", "c:\\Any\\Other\\Directory\\temp2.pdf");
// NOT WORK.

Ideally I would like to put the PDF documents below some 'well known'
reports folder, such as C:\\Data\\Reports\\blah but I can't get it to
work.

Please help.

Regards
 
H

Hans Kesting

Hi,
Confused about loading a pdf file into an iframe from C# code behind.

I have a PDF file called temp2.pdf in my document root. The file is
physically located at C:\inetpub\wwwroot\MySite\temp2.pdf .

In the code behind I try:

Iframe1.Attributes.Add("src", "\\MySite\\temp2.pdf"); // THIS WORKS
Iframe1.Attributes.Add("src",
"c:\\inetpub\\wwwroot\\MySite\\temp2.pdf"); // NOT WORK.
Iframe1.Attributes.Add("src", "c:\\Any\\Other\\Directory\\temp2.pdf");
// NOT WORK.

Ideally I would like to put the PDF documents below some 'well known'
reports folder, such as C:\\Data\\Reports\\blah but I can't get it to
work.

Please help.

Regards

The browser has to be able to get at that file, by way of IIS. If the
directory where the PDFs are is outside of the website, IIS can't serve
it to the browser.
So either place those files insite the website directory (maybe in a
subdirectory of your choice), OR add some "upload.aspx" to your site
that can get the PDF file from it's directory elsewhere and pass it on
to the browser (see Response.WriteFile)

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top