Unwanted output when using Response.Flush()
<p>I have an asp.net (.aspx) page containing a button. When I click that button I wish for some content (given as a byte array and created in my code-behind) to be written into a text
file and downloaded to the user (Open\Save..).
I use the following button click handler syntax:</p>

<pre><code>  Response.Buffer = true;
            Response.Charset = "";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = "text/plain";
            Response.AddHeader("content-disposition", "attachment;filename=" + "non-queries.txt");
            Response.BinaryWrite(\*Here I send the byte array*\);
            Response.Flush();
</code></pre>

<p>Now the content of the byte array does get written into the file, but what also gets written is the html content of the aspx page containing the button, which I don't want written.</p>

<p>Can you help? Where do I go wrong?</p>
