ASP.NET: JS callback when form submit returns file to download
<p>I have an ASPX form page  that works synchronously (no AJAX!).</p>

<p>One of the buttons on this page returns a file to be downloaded by writing it directly into response stream:</p>

<pre><code>Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment; filename=logfile.txt");
Response.TransmitFile(Server.MapPath("~/wmtest.docx"));
Response.End();
</code></pre>

<p>I need a javascript callback to be called on the page when response is returned,  just before or after browser displays the "download file" dialog.</p>

<p>Is there any way to do that?</p>

<p><strong>Note:</strong> It's not real phisical file existing on the server that can be accessed or downloaded by URL, but a file that is generated and returned within request, so returning file's URL and then making it to be downloaded with JS on the client side is not an option</p>

<p>Thanks in advance!
- Michael</p>