sending file from server to client ??

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
 
N

nn

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top