generate xml file and allow user to download it...

Discussion in 'ASP .Net' started by John Q. Adams, Oct 13, 2006.

  1. I want to generate an XML file on the server side and allow the user to
    download it by clicking on a link. I also want the XML file to always be
    named "Config.XML"

    Whats the best way to do this?

    If I create an ASP.NET page called Config.aspx, I can generate the XML file
    (and change the mime type). However, when the user tries to save it on his
    desktop, IE names it Config.aspx instead of Config.xml.

    Is there a clean simple way to generate the XML on the server side and give
    it to the user as a download link that he can just save? Maybe I need to
    save a temp file on the server side and give that to the user as a download
    link. But then how do I handle multiple users who all need a Config.xml
    file?

    Thanks!!
     
    John Q. Adams, Oct 13, 2006
    #1
    1. Advertising

  2. You can set the filename by providing a "content-disposition" HTTP
    header, e.g.

    Response.ContentType = "text/xml";
    Response.AppendHeader("content-disposition",
    "attachment;filename=Config.xml");
    Response.Write(myXmlDoc.DocumentElement.OuterXml);
    Response.End();

    John Q. Adams wrote:
    > I want to generate an XML file on the server side and allow the user to
    > download it by clicking on a link. I also want the XML file to always be
    > named "Config.XML"
    >
    > Whats the best way to do this?
    >
    > If I create an ASP.NET page called Config.aspx, I can generate the XML file
    > (and change the mime type). However, when the user tries to save it on his
    > desktop, IE names it Config.aspx instead of Config.xml.
    >
    > Is there a clean simple way to generate the XML on the server side and give
    > it to the user as a download link that he can just save? Maybe I need to
    > save a temp file on the server side and give that to the user as a download
    > link. But then how do I handle multiple users who all need a Config.xml
    > file?
    >
    > Thanks!!
     
    Chris Fulstow, Oct 13, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff
    Replies:
    2
    Views:
    979
    clintonG
    Sep 19, 2006
  2. Harlan Messinger
    Replies:
    2
    Views:
    2,346
    John Bell
    Mar 28, 2010
  3. Ryan Taylor
    Replies:
    1
    Views:
    710
    Ryan Taylor
    Sep 9, 2004
  4. Replies:
    1
    Views:
    116
    Bob Barrows [MVP]
    Mar 26, 2008
  5. fedekun

    Download file, allow cookies

    fedekun, Aug 2, 2009, in forum: Ruby
    Replies:
    0
    Views:
    107
    fedekun
    Aug 2, 2009
Loading...

Share This Page