Response is not available in this context?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/8586201/response-is-not-available-in-context-how-to-solve-it">Response is not available in context? How to solve it?</a>  </p>
</blockquote>



<p>I want to sent a pdf file to client as attachement. I try to use Response object to achieve it. But come up with error.</p>

<pre><code>Response.Buffer = false;
            Response.Clear();
            Response.ClearContent();
            Response.ClearHeaders();

            //Set the appropriate ContentType.
            Response.AppendHeader("Content-Disposition", "attachment; filename="+Server.MapPath(@".\test.pdf"));
            Response.ContentType = "Application/pdf";

            //Write the pdfStream into Response
            Response.BinaryWrite(pdfData);
            Response.Flush();
            Response.End(); 
</code></pre>

<p>But always throw the "Response is not available in this context". If anyone can help me?</p>

<p>PS:I save a pdf file as stream(pdfData).</p>

<p>Thanks in advance.</p>
