Search code examples
asp.netxmlzipgzipxmlwriter

Stream SQL FOR XML into response and zip


I have a SQL FOR XML query which I am streaming straight into the response via a .net XmlWriter.

Is it possible to GZIP this directly into the response?

We have some massive XML files (over 2 million items with multiple attributes - the raw files are several GB once created) which we are distributing to our customers. Up until now we have been unable to compress without first creating a file or writing to memory. However, both of these have massive performance bottlenecks in terms of IO and memory capacity.

If anyone can provide some advice its greatly appreciated. I'm happy to provide any additional info that can help.

Thanks


Solution

  • Yes you can do this. Have a look at ionic.zip as an example, there are other .NET components that let you create a ZIP on the fly and stream it back to the browser in the response.