I have an ASP.NET Web Forms application. Once the user clicks on a download link, I need to create several XMLs file on the fly, zip them and prompt the user with a download dialog.
I already made the function to download a single XML file and it works correctly. The link in the download.aspx file is:
<asp:HyperLink ID="hlDownload" Text="Download" NavigateUrl='<%# String.Format("GetFile.aspx?LicenseGuid={0}", Eval("ProductId")) %>' runat="server"></asp:HyperLink>
The function in the GetFile.aspx code behind:
Dim xmlFile = _productServices.GetXMLFilePerProductId(ProductId)
Dim xdoc As XmlDocument = New XmlDocument()
xdoc.LoadXml(xmlFile)
Response.Clear()
Response.ContentType = "text/xml"
Response.ContentEncoding = System.Text.Encoding.UTF8
Response.AddHeader("Content-Disposition", "attachment; filename=some_name.xml")
xdoc.Save(Response.Output)
Response.End()
How can I create a ZIP file on the fly and pack a couple of XML files, created on the fly as well?
PS: answers in both C# and VB.NET are welcome