sending file from server to client ??

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Hi,

In ASP.NET do I want to sent a file from the server to the client and tried
the following :


byte[] sendData = Encoding.ASCII.GetBytes(strXmlContent);
// strXmlContent is a string that contains the contents of a file
Response.AddHeader("content-disposition","attachment;");
Response.OutputStream.Write(sendData, 0, sendData.Length);

The result is that the client gets a "File Save as..." dlgBox allowing me to
save the contents. OK.
Problem is that not only 'strXmlContent' was saved but the contents of the
HTML-page as well !!

Is there a way to separate the 2 ?
Or another way to send a file from server to client ?

thnx
Chris
 
Chris said:
byte[] sendData = Encoding.ASCII.GetBytes(strXmlContent);
// strXmlContent is a string that contains the contents of a file
Response.AddHeader("content-disposition","attachment;");
Response.OutputStream.Write(sendData, 0, sendData.Length);

Try add Response.Clear before Response.OutputStream.Write ...
and Response.End after that.
 
Back
Top