My application pushes out a PDF file to a popup (e.g. no menu/toolbar) browser window (in response to the user clicking a button). This works for every browser out there except for IE7. In IE7, all I get is a blank window.
Here is the server-side code that pushes out the PDF:
private void StreamPDFReport(string ReportPath, HttpContext context)
{
context.Response.Buffer = false;
context.Response.Clear();
context.Response.ClearContent();
context.Response.ClearHeaders();
// Set the appropriate ContentType.
context.Response.ContentType = "application/pdf";
context.Response.AddHeader("Content-Disposition", "inline; filename=Report.pdf");
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
// Write the file directly to the HTTP content output stream.
context.Response.WriteFile(ReportPath);
HttpContext.Current.ApplicationInstance.CompleteRequest();
//context.Response.End();
}
On the client side, when the user presses the button, the following happens in the onClick handler:
onclick="window.open('RptHandler.ashx?RptType=CaseInfo', 'Report', 'top=10,left=10,width=1000,height=750')
Am I missing something really basic? Why does it work in every browser but not IE?
It turns out that the following statement causes IE to not display the PDF:
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
Not sure why.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With