Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Diagram disappears after Response.TransmitFile (Read 6742 times)
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
Diagram disappears after Response.TransmitFile
Mar 18th, 2013 at 7:18pm
Print Post  
Hi,

This has been a challenging problem to troubleshoot.
I have a page on which I render a diagram.  That works fine.
I am displaying one activity for a process with several activities.
The user clicks on a button that causes ALL activities (not just the current one they are looking at) to be exported to a PDF document.
When this code completes, the user is prompted to Open or Save the document (actual dialog varies by browser).

So, here's my problem.
The export works fine, but the diagram that was on the screen prior to the export button being clicked sometimes disappears.  I modified the code behind to regenerate the diagram and that seems to have made things better, but I still have instances when the diagram does not appear - just white space.

It would be rather difficult to create a simple project that demonstrates this issue, so I've provided a summary of what happens below:

Code
Select All
Export To PDF Button clicked
...
  // The following will cause a script to run after this ajax request completes that results in the ViewAttachments page to be loaded
  // This page in turn will transmit the newly created document to the browser
  RadAjaxPanel MstrPanel1 = (RadAjaxPanel)Master.FindControl("MstrPanel1");
  MstrPanel1.ResponseScripts.Add(String.Format(@"window.location.href = ""{0}"";", "ViewAttachments.aspx?Path=ExternalDocs&Delete=No"));
...
A PDF including ALL activities for the current process is created
 - multiple diagrams are created, saved as PDF and then these PDF's merged into a single document
...
The diagram originally displayed is regenerated
...
The code behind is complete
...
The response script registered above will now cause page ViewAttachmenets.aspx to be loaded.
The Page_Load in this page will transmit the file to the browser:
...
  Response.TransmitFile(path + Session["Attachment"].ToString());

 



This seems to be working fine in Chrome and FireFox but not IE (versions 7 thru 9). 

Any thoughts on how I might fix this, or get a better handle on what is happening?

Thanks in advance.

Jim
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram disappears after Response.TransmitFile
Reply #1 - Mar 18th, 2013 at 7:43pm
Print Post  
Hi,

If you open the PDF file saved by IE with a hex editor, can you see anything looking like HTML markup appended to it?

Stoyan
  
Back to top
 
IP Logged
 
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
Re: Diagram disappears after Response.TransmitFile
Reply #2 - Mar 18th, 2013 at 8:42pm
Print Post  
Hi,

Here's a screenshot from a hex editor.
Looks like a normal end of file to me.

Jim
  

PDF_Hex_Dump.png (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram disappears after Response.TransmitFile
Reply #3 - Mar 19th, 2013 at 6:46am
Print Post  
Does the IE's View Source command show complete HTML code when the diagram disappears?
  
Back to top
 
IP Logged
 
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
Re: Diagram disappears after Response.TransmitFile
Reply #4 - Mar 19th, 2013 at 12:07pm
Print Post  
Hi,

I have attached a zip file that contains the HTML for the page with the diagram showing (before PDF Export) and for the same page without the diagram visible (after the PDF Export).
One thing I failed to mention before, is that I am disabling AJAX when the request is initially made since this seems to be necessary in order for the export to work at all.

For the attached files I was running IE8 in IE Standards mode.

'Hope this helps.

Jim
  

Disappearing_Diagram_-_View_Source.zip (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram disappears after Response.TransmitFile
Reply #5 - Mar 20th, 2013 at 8:27am
Print Post  
If you set a breakpoint inside Page_Load method in ImageGen.aspx.cs, can you see it called after generating the PDF?
  
Back to top
 
IP Logged
 
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
Re: Diagram disappears after Response.TransmitFile
Reply #6 - Mar 20th, 2013 at 7:19pm
Print Post  
Yes, the code does fire after the PDF export.
Jim
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram disappears after Response.TransmitFile
Reply #7 - Mar 20th, 2013 at 8:21pm
Print Post  
If you edit ImageGen.cs to create a FileStream for a new file with extension corresponding to view.ImageFormat, and then call fileStream.Write(data, 0, data.Length); does the file show the correct diagram image?
  
Back to top
 
IP Logged
 
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
Re: Diagram disappears after Response.TransmitFile
Reply #8 - Mar 21st, 2013 at 5:57pm
Print Post  
Hi,

Thanks for the suggestions, but I have resolved this issue.
Without getting into the code, I performed the PDF export on the server side and then ended the request.  Javascript on the client then did a window.open for the page that did the transmitfile.  This is working fine now.

Seemed like it was a timing issue as it would work sometimes.

Thanks for your assistance.

Jim
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint