How to create and download an XML without storing it on the server
- by CiccioMiami
NET Web Forms** application. I would like to create a download link to make available to the user the possibility to download an XML file. However the file does not have to be stored on the server.
In my aspx file I have the download link (placed inside a GridView):
<asp:HyperLinField Text="Download" DataNavigateUrlFormatString="download.aspx?ProductId={0}" DataNavigateUrlFields="ProductId">
In the download.aspx.vb page:
Dim productId As String = Request.QueryString("productId")
Dim xmlDoc As String = _ProductServices.GetXmlDocPerId(productId)
Dim xdoc As XmlDocument = New XmlDocument()
xdoc.LoadXml(xmlLicense)
Now I would like to create a file, place the XML content inside and deliver it to the user without saving it to the server. Shall I use a MemoryStream combined with a StreamReader?