We have an intranet system that display into a web browser PDF stored in SQL, this work perfect with Adobe Reader but recently a big number of users started using the PDF Xchange Editor and we noticed that the users with PDF Xchange editor when they click on the link to display the PDF inside the IE Browser is running the page_load twice, the first time with all the parameters to open the correct PDF and then again without any parameter.
The code to stream the pdf to the browse is simple:
We have the PDF Binary in a memorystream PDFStream
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "inline; filename=DOCPDF.pdf");
Response.AddHeader("content-length", PdfStream.Length.ToString());
Response.BinaryWrite(PdfStream.ToArray());
Response.Flush();
Response.End();
When Adobe reader, the page is finishing after the Response.End(), but for some reason when the client have PDF Xchange, the page_load start over after the Response.End().
Any idea what to do to be sure it only load one time?
Thank you.
PDF-XChange editor and Response.BinaryWrite
Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
Re: PDF-XChange editor and Response.BinaryWrite
I tried this code .... same result
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/pdf";
HttpContext.Current.Response.AddHeader("content-disposition", "inline; filename=DOCPDF.pdf");
HttpContext.Current.Response.AddHeader("content-length", PdfStream.Length.ToString());
HttpContext.Current.Response.BinaryWrite(PdfStream.ToArray());
HttpContext.Current.Response.Flush(); // Sends all currently buffered output to the client.
HttpContext.Current.Response.SuppressContent = true;
HttpContext.Current.ApplicationInstance.CompleteRequest();
it will trigger again the page_load only when using PDF Xchange Editor viewer.
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/pdf";
HttpContext.Current.Response.AddHeader("content-disposition", "inline; filename=DOCPDF.pdf");
HttpContext.Current.Response.AddHeader("content-length", PdfStream.Length.ToString());
HttpContext.Current.Response.BinaryWrite(PdfStream.ToArray());
HttpContext.Current.Response.Flush(); // Sends all currently buffered output to the client.
HttpContext.Current.Response.SuppressContent = true;
HttpContext.Current.ApplicationInstance.CompleteRequest();
it will trigger again the page_load only when using PDF Xchange Editor viewer.
- Tracker Supp-Stefan
- Site Admin
- Posts: 17941
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: PDF-XChange editor and Response.BinaryWrite
Hello cguanes,
Could you please prepare a sample project that can illustrate the problem and send that to us along with any sample files necessary?
Kind regards,
Stefan
Could you please prepare a sample project that can illustrate the problem and send that to us along with any sample files necessary?
Kind regards,
Stefan
Re: PDF-XChange editor and Response.BinaryWrite
attached to this you will find a small project example, just reading a pdf file into memorystream and writing to stream.
If you put a break point on the first line of Page_load, you will see the page_load is being called twice, that is not happening with Adobe reader.
Of course my original project is more complex including SQL updates and running twice is affecting the way that it should work.
You can try with this code using the response.end() or the other example posted before using HttpContext.Current.ApplicationInstance.CompleteRequest();
If you put a break point on the first line of Page_load, you will see the page_load is being called twice, that is not happening with Adobe reader.
Of course my original project is more complex including SQL updates and running twice is affecting the way that it should work.
You can try with this code using the response.end() or the other example posted before using HttpContext.Current.ApplicationInstance.CompleteRequest();
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: PDF-XChange editor and Response.BinaryWrite
Hi cguanes.
Thanks for your clear sample project - we reproduced the problem. At the moment we detected that the issue is caused by our Sharepoint-plugin for our PDF Editor. So, as temporary workaround - you may turn OFF this plugin here:
(IE > EmbeddedPdfEditor > File > Preferences, and restart the IE)
We will try to fix this trouble in the near future. Thanks for the detailed report.
Cheers.
Thanks for your clear sample project - we reproduced the problem. At the moment we detected that the issue is caused by our Sharepoint-plugin for our PDF Editor. So, as temporary workaround - you may turn OFF this plugin here:
(IE > EmbeddedPdfEditor > File > Preferences, and restart the IE)
We will try to fix this trouble in the near future. Thanks for the detailed report.
Cheers.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: PDF-XChange editor and Response.BinaryWrite
There is another possibility to solve your problem. When the Editor trying to detect if it is talking with a Sharepoint server, it sends HTTP 'HEAD' request. But looks like your server app responds to the 'HEAD' request like as to regular 'GET' request sending all including response body again. So if you can detect HTTP verb and send only headers in case of 'HEAD' request, I guess it will solve the issue.
I just checked the Page_load::sender.Request.RequestType at second call:
- the RequestType=='HEAD' as expected...
I just checked the Page_load::sender.Request.RequestType at second call:
- the RequestType=='HEAD' as expected...
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: PDF-XChange editor and Response.BinaryWrite
I will try this
- Radi - Tracker Supp
- Site Admin
- Posts: 600
- Joined: Tue Mar 03, 2015 12:46 pm