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

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!!
 
C

Chris Fulstow

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();
 

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

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top