I just want to be able to press on a button and get an xmldocument file to download.
I’ve tried allot of things, for example:
XmlDocument doc As XmlDocument() = //Method that gets a xmldocument
Response.Clear()
this.Response.ContentType = "text/xml"
xmldoc.Save(this.Response.OutputStream)
and
Dim xmldocument As XmlDocument = //Method that gets a xmldocument
Using stream As MemoryStream = New MemoryStream()
Dim xmlWriter As XmlTextWriter = New XmlTextWriter(stream, System.Text.Encoding.ASCII)
xmldocument.WriteTo(xmlWriter)
xmlWriter.Flush()
Dim byteArray As Byte() = stream.ToArray()
Response.Clear()
Response.AppendHeader("Content-Disposition", "filename=MyExportedFile.xml")
Response.AppendHeader("Content-Length", byteArray.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.BinaryWrite(byteArray)
xmlWriter.Close()
End Using
Nothing works, am i forgetting something obvious? because nothing works, the xmldocument is loaded everything seems fine but the file never downloads and the “response” does absolutely nothing!
An answer in Csharp or VB.NET would be helpfull
Try something like this