I have an object that i serialized and now is represented as an instance of the XmlDocument.
XmlSerializer ser = new XmlSerializer(typeof(MyType));
System.Text.StringBuilder sb = new System.Text.StringBuilder();
System.IO.StringWriter writer = new System.IO.StringWriter(sb);
ser.Serialize(writer, myObj);
XmlDocument doc = new XmlDocument();
doc.LoadXml(sb.ToString());
I want the user to be able to download the xml file that the XmlDocument represents. How can i do so without first saving the XmlDocument as a File on the server file system?
gil.tankus
Member
143 Points
53 Posts
Downloading a XML file
Apr 06, 2012 02:38 PM|LINK
Hello,
I have an object that i serialized and now is represented as an instance of the XmlDocument.
I want the user to be able to download the xml file that the XmlDocument represents. How can i do so without first saving the XmlDocument as a File on the server file system?
DarrellNorto...
All-Star
86665 Points
9634 Posts
Moderator
MVP
Re: Downloading a XML file
Apr 06, 2012 02:54 PM|LINK
Try this:
ResponseAddHeader("Content-Disposition", "attachment; filename=\"myXmlFile.xml"); // forces download as an attachment, not rendering inlineDarrell Norton's Blog
Please click "Mark as Answer" if this helped you.
all-alone808
Member
290 Points
75 Posts
Re: Downloading a XML file
Apr 06, 2012 07:16 PM|LINK
http://www.west-wind.com/weblog/posts/2007/May/21/Downloading-a-File-with-a-Save-As-Dialog-in-ASPNET
http://bytes.com/topic/asp-net/answers/287887-how-downloas-xml-file