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

  • Thread starter Thread starter John Q. Adams
  • Start date Start date
J

John Q. Adams

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!!
 
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();
 
Back
Top