.NET, ASHX, "Server cannot append header after HTTP headers have been sent" after sending PDF Streem
<p>I visit my ASHX file, and it outputs a PDF perfectly.  If I visit the very same ASHX with a different query string (I append DateTime.Now.Ticks to the end each visit), and I get this error:</p>

<p>Server cannot append hader after HTTP headers have been sent.</p>

<p>My code is below:</p>

<pre><code>copy.CloseStream = false;
document.Close();

var r = context.Response;
r.ExpiresAbsolute = DateTime.Now;
r.BufferOutput = true;
r.ContentType = "application/pdf";
r.AppendHeader("Content-Type", r.ContentType);
r.AppendHeader("Content-disposition", "inline; filename=" + context.Server.UrlEncode(formType.File_Name));

r.BinaryWrite(copyStream.ToArray());
r.StatusCode = 200;
r.End();
originalReader.Close();
copy.CloseStream = true;
copy.Close();
</code></pre>

<p>There is no other place in this code that headers are sent.  You are seeing the entire interaction with the Response object.</p>

<p>I've tried to use <code>r.Flush();</code> and <code>r.End();</code>  I've also tried not sending them if they are already there, but this causes other issues.  </p>
