I was debugging some ASP.Net 2.0 code that renders a PDF to the response buffer of a page request, using code like this (byte[] bytes is the PDF file, which was rendered using Microsoft Reporting Services Web Service interface) :
public static void DownloadBytes(byte[] bytes, string mimeType, string fileName) {
HttpResponse r = HttpContext.Current.Response;
r.ContentType = mimeType;
r.AppendHeader("Content-Disposition", "attachment;filename=" + fileName);
r.BinaryWrite(bytes);
r.Flush();
r.End();
}
I found that an exception was being raised when r.End() was called, and it turned out to be a sneaky little guy by the name ...