M
msxkim
My web app writes some binary data to a file at the client site via
Response.BinaryWrite. This action is accomplished
in response to a button click, with C# code behind as follows:
private void SubmitButton_Click (object sender, System.EventArgs e)
{
// Set up the response to write the print file to the client
Response.Clear ();
Response.Buffer=false;
Response.AppendHeader ("Content-Disposition",
"filename=WebPrint.prn");
Response.AppendHeader ("Content-Length", filename.length.ToString
());
Response.ContentType = "application/octet-stream";
Response.BinaryWrite (buf); // Write binary data
Response.Flush();
Response.End ();
}
This works fine for first time. User sees a File Save As dialog box
and download a file to the local drive. But my problem is that when
user clicks 'Download' button again, the browser is filled with junk
funny characters. If I close the browser after the download and open
it again then click download button, it works always. Most of time, I
get this behavior when I click download button for the second time,
sometimes third click.
Please help.
Response.BinaryWrite. This action is accomplished
in response to a button click, with C# code behind as follows:
private void SubmitButton_Click (object sender, System.EventArgs e)
{
// Set up the response to write the print file to the client
Response.Clear ();
Response.Buffer=false;
Response.AppendHeader ("Content-Disposition",
"filename=WebPrint.prn");
Response.AppendHeader ("Content-Length", filename.length.ToString
());
Response.ContentType = "application/octet-stream";
Response.BinaryWrite (buf); // Write binary data
Response.Flush();
Response.End ();
}
This works fine for first time. User sees a File Save As dialog box
and download a file to the local drive. But my problem is that when
user clicks 'Download' button again, the browser is filled with junk
funny characters. If I close the browser after the download and open
it again then click download button, it works always. Most of time, I
get this behavior when I click download button for the second time,
sometimes third click.
Please help.