I have a process that sends a PDF to the user via
Response.BinaryWrite(pdf);
After this completes, I want to
Response.Redirect("Default.aspx");
The problem is that the redirect fires before the BinaryWrite()
has completed. I know this because I do not see the popup to download the PDF as I should.
If I remove
Response.Redirect("Default.aspx");
Then I get the popup as I should. So, there's a race condition here (probably has something to do with HTTP being connectionless). I could do
Thread.Sleep(5000);
But that is ridiculous. Is there a good solution to this problem?
I tried AJAX. This isn't working either. Due to an issue with AJAX and popups, I have to use the workaround
window.frames["#pdfPopup"].location.reload();
To get my popup to display.
Then this code never runs...
alert('before href');//no alert ever displays
window.location.href = "http://www.yahoo.com/";
This could be because I called reload(). Any ideas?
I hooked into onload for the frame, but this still doesnt work! Ugh. I read that onload does not fire for frames that contain activeX controls, including PDF. I read this on SO and multiple google sites.
<iframe id="pdfPopup" style="visibility:hidden;height:0px;width:0px;" onload="Redirect();"></iframe>
onload does fire on page load, but not when I call reload and put a PDF in there. So I have hit a brick wall. Anybody have any solutions for this?