PDF in modal iframe makes blank in IE

EDIT 2

It seems that moving the object tag in Dom is causing the problem. I added an iframe directly to the page and it works great without any problems.

However, when I move this iFrame to the modal dialog box ( http://www.ericmmartin.com/projects/simplemodal/ ), the PDF disappears (the object tag no longer displays correctly).

So, it seems that this is no longer a question about my handler, but a question about why moving the "object" tag (or embedding) in the DOM (which lives inside the iFrame) leads to a "skip". "

In addition, when pdf moves from the modal dialog back to its original position, it displays correctly. Therefore, perhaps I should focus more on the modal dialogue itself.

Thoughts? Thanks for your suggestions.


EDIT 1

So, I made some changes for testing.

I have an iframe to output an object tag for PDF requests along with 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 the page with the current time correctly, but the object only displays the PDF for the first time after publishing the aspx page. So this seems to be some kind of caching issue? Except that the object does not load anything (not even a previously downloaded PDF).

If you right-click on the iframe and refresh the page, the object will load normally. (The same is true if I use the embed tag).


Original question

, ...

, .

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

PDF, , ( ). :

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();

(doc, txt, xls, html) iframe ( ) pdf. iframe, .

, , - , aspx, . ( ). Firefox PDF , , .

:

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

.pdf

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

URL ,

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

Un-

IIS, , IIS.

, iFrame, ( ).

!

.

+3
4

, IE.

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

pdf iframe , , ...

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();
}
+1

, PDF SSL ( IE, FF ), :

Response.ClearHeaders();
Response.ClearContent();
Response.Buffer = true;

Response.AppendHeader("Content-Disposition", "inline; attachment; filename=Filename.pdf");
Response.ContentType = "application/pdf";

Response.WriteFile(path);

Response.Flush();
Response.End();
+1

, , .pdf. PDF :

Response.Clear();
Response.ContentType = "application/pdf";
Response.BinaryWrite(pdfBuffer);
Response.Flush();

, - application/pdf CLSID .

0

(pdf Internet Explorer) iframe. pdf html-. . :

http://intranation.com/test-cases/object-vs-iframe/

: , :

jQuery floatbox, load html fragment with iframe, load aspx page in iframe, load pdf into aspx page

A setting that now works:

jQuery floatbox, loads an html fragment, adds an object element. before adding an object element, set the data attribute of the object element to the aspx page url

0
source

Source: https://habr.com/ru/post/1765334/