Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1081679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:11:57+00:00 2026-05-16T22:11:57+00:00

EDIT 2 It appears that moving the object tag in the Dom is the

  • 0

EDIT 2

It appears that moving the object tag in the Dom is the cause of the problem. I added an iframe directly to the page and it works fine without any problems.

However, when I move that iFrame into a modal dialogue box (http://www.ericmmartin.com/projects/simplemodal/) the PDF disappears (the object tag no longer renders correctly).

So it appears that it’s no longer a question about my handler, but more a question about why moving the “object” (or embed) tag in the DOM (which lives inside an iFrame) causes it to “blank-out.”

Also, when the pdf is moved from the modal dialogue back to its original position, it appears correctly. So, perhaps I should focus more on the modal dialogue itself.

Thoughts? Thanks for your suggestions thus far.


EDIT 1

So I’ve made some modifications for testing.

I’ve got the iframe to output an object tag for pdf requests along with the server time.

Response.AddHeader("content-type", "text/html");
WebClient client = new WebClient();
Response.Write("<html><head></head><body><h1>"+ DateTime.Now.ToString() + "</h1><object height='100%' width='100%' name='plugin' data='" + Request.Url.ToString() + "&embed=true' type='application/pdf' /></body></html>");
Response.Flush();
Response.Close();
Response.End();

Now I get a page with the current time correctly, but the object only displays the PDF the first time after I publish the aspx page. So it appears to be some sort of caching issue? Except that the object isn’t loading anything (not even the previously loaded PDF).

If right click on the iframe and refresh the page, the object loads up fine. (The same is true if I use an embed tag).


Original Question

I know there are a lot of questions on this…

  • streaming PDF data through an ASPX page
  • Server generated PDF not displaying in IFrame on aspx page on some (but not all )PCs
  • Displaying a PDF Document in ASP.net page

But they either weren’t answered, or the answer didn’t work.

Environment

  • .Net 4
  • Adobe 9.3.4
  • IIS 5.1
  • XP sp3
  • VS 2010
  • IE 8.0.6001.18702

Background

The pdf’s I’m streaming come from a storage repository where the files don’t have any extensions (this is done for security). I look up the file in the database and stream it back to the client via the following code:

Response.Clear();
WebClient client = new WebClient();
Byte[] buffer = client.DownloadData(sPath);
Response.AddHeader("content-length", buffer.Length.ToString());
Response.AddHeader("content-disposition", "inline;filename=" + fileName);
Response.AddHeader("expires", "0");
Response.AddHeader("Content-Type", "application/pdf"); //this is usually dynamic to support other types (doc, xls, txt, etc.)
Response.OutputStream.Write(buffer, 0, buffer.Length);
Response.Flush();
Response.Close();
Response.End();

This works for every file type (doc, txt, xls, html) when used directly in the browser or in the iframe (displayed as a modal popup) with the exception of pdf files. They do not work reliably when accessed via the iframe, but work fine when accessed directly in the browser.

The only time it does work is the first time I request a document after I publish the aspx page that is serving these files. All subsequent hits return a blank page (even from new tabs or browser windows). Firefox reliably displays the pdf every time regardless.

Attempted Solutions

I’ve tried various ways I of streaming the file:

Response.TransmitFile(sPath);
Response.WriteFile(sPath);
//As well as some others

I’ve tried adding .pdf to a parameter at the end of the request

http://www.myurl.aspx?File=test.pdf

I’ve tried making the URL unique by adding a time stamp

http://www.myurl.aspx?File=test.pdf&Unique=Friday__September_17__2010_12_02_16_PM

Un-Attempted

I’ve read about IIS compression causing problems, but it was for a newer version of IIS.

Didn’t try using embed tag since I would like to stick to the iFrame if possible (The existing infrastructure uses it).

Any help would be greatly appreciated!!!

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:11:58+00:00Added an answer on May 16, 2026 at 10:11 pm

    So I gave up and decided to use a standard IE popup window instead.

    window.open(URL, 'Window', 'height=' + pageHeight + ',width=' + pageWidth + ',top=0,left=0,resizable');
    

    I had to render the pdfs in an object tag and everything else inside an iframe within the popup for it to work, but it works…

    if (sDocType == "pdf")
    {
        Response.AddHeader("content-type", "text/html");
        WebClient client = new WebClient();
        Response.Write("<html style='margin:0px;padding:0px;'><head></head><body style='margin:0px;padding:0px;'><object height='100%' width='100%' name='plugin' data='" + Request.Url.ToString() + "&embed=true' type='" + zGetContentType(HttpContext.Current.Request.QueryString["docType"]) + "'><param name='src' value='" + Request.Url.ToString() + "&embed=true' />alt : <a href='" + Request.Url.ToString() + "&embed=true'>View</a></object></body></html>");
        Response.Flush();
        Response.Close();
        Response.End();
    }
    else
    {
        Response.AddHeader("content-type", "text/html");
        WebClient client = new WebClient();
        Response.Write("<html style='margin:0px;padding:0px;'><head></head><body style='margin:0px;padding:0px;'><iframe frameborder='0' scrolling='no' height='100%' width='100%' src='" + Request.Url.ToString() + "&embed=true' /></body></html>");
        Response.Flush();
        Response.Close();
        Response.End();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Plugging in to Java compilers Edit - this appears to be a
I am trying to remove/edit the text shown in the picture which appears from
EDIT: I was an idiot. I simply had an image that was vertically long,
EDIT: See my answer below--> I am wanting to have a view that when
EDIT: iam using ajax to load text in my content that is why onload
Edit : Note that, as Daniel and latkin noted in an answer and a
EDIT : It turned out that this can only be done through an external
EDIT: Mangling is fixed - primary issue appears to be the php/mysql connection In
It appears that on Windows 7 Cygwin/vim thinks all files are read only. You
SOLVED - the problem is that doing a rotation puts half of the element

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.