Problem with postback after Response.Write

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Russ (russk2_at_eticomm.net)
Date: 10/06/04


Date: Wed, 06 Oct 2004 14:18:28 -0400

My web app writes some binary data to a file at the client site via
Response.Write and 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.AppendHeader ("Content-Disposition",
      "filename=WebPrint.prn");
  Response.ContentType = "application/octet-stream";

  int len = CalcLength ()
  Response.AppendHeader ("Content-Length", len.ToString ());

  Response.Write (s); // Write some string data
  Response.BinaryWrite (buf); // Write binary data
  Response.End ();
}

This works fine. But my problem is that after the browser puts up the
File Download box and the user saves the file, the page does not get
posted back. After the file is downloaded I need to transfer control
to another page, and I can find no way to do it.

I've tried replacing Response.End with Response.Redirect with no
effect. Adding Server.Transfer after Response.End, or even in place
of it has no effect - I can trace the code and the function is called,
but the page is never posted back so the action does not happen.

Help???

Thanks, Russ



Relevant Pages

  • Download file, browser is filled with funny characters.
    ... My web app writes some binary data to a file at the client site via ... // Set up the response to write the print file to the client ... and download a file to the local drive. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: POSTing a file to a web page and reading response
    ... binary data. ... server and read back the server's response. ... HttpURLConnection conn = ... DataOutputStream dos; ...
    (comp.lang.java.programmer)
  • CAB binary data over servlet response
    ... I created a servlet which sends CAB binary data on the servlet ... The binary data is contained in a byte array. ... I join the sample of code which sends the byte array over the response ...
    (comp.lang.java.programmer)
  • CAB binary data over servlet response
    ... I created a servlet which sends CAB binary data on the servlet ... The binary data is contained in a byte array. ... I join the sample of code which sends the byte array over the response ...
    (de.comp.lang.java)
  • Re: IO Stream HELP URGENT!!!
    ... This will fill a byte array with the content of "stream" and write to the ... always clear the response before writing binary data, ... > Response.BinaryWrite does not accept a stream data type. ...
    (microsoft.public.dotnet.languages.csharp)