sending file from server to client ??

Discussion in 'ASP .Net' started by Chris, Oct 15, 2004.

  1. Chris

    Chris Guest


    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.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 ?

    Chris, Oct 15, 2004
    1. Advertisements

  2. Chris

    nn Guest

    Try add Response.Clear before Response.OutputStream.Write ...
    and Response.End after that.
    nn, Oct 15, 2004
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.