I have a simple HTTP handler that allows our users to retrieve a PDF file stored remotely. Surprisingly, this code works well when the handler is called from IE9 but IE8 stays stuck. You have to call the url a second time to get the pdf displayed correctly.
I checked on the web to see if there was something further to do with the response. I initially thought that the response was not properly ended, but found the below article: http://blogs.msdn.com/b/aspnetue/archive/2010/05/25/response-end-response-close-and-how-customer-feedback-helps-us-improve-msdn-documentation.aspx Apparently, the context.Response.Close() or the context.Response.End() should not be used.
The code I am using:
using System.Web;
namespace WebFront.Documents
{
public class PDFDownloader : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
// Makes sure the page does not get cached
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
// Retrieves the PDF
byte[] PDFContent = BL.PDFGenerator.GetPDF(context.Request.QueryString["DocNumber"]);
// Send it back to the client
context.Response.ContentType = "application/pdf";
context.Response.BinaryWrite(PDFContent);
context.Response.Flush();
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
Did anyone faced the same type of issue?