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:
URL ,
http:
Un-
IIS, , IIS.
, iFrame, ( ).
!
.