Developer forum

Forum » Development » Bypass GZip compression for a specific page

Bypass GZip compression for a specific page

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

I have a page based on an item with a custom Razor template that outputs data as a CSV file (along with the appropriate header and such). I also have GZip compression turned on in the Settings area. When GZip is turned on, my CSV becomes much like a ZIP file. When I download it, and rename it to zip, I can look into it and see my CSV file / data.

How do I prevent GZip compression from happening on this page only without turning it off for the rest of the site? 

Thanks!

Imar


Replies

 
Nicolai Pedersen
Reply

You set a response type on the page properties - that will disable compression for a given page.

Capture.PNG
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Yeah, I tried that already, but it doesn't make a difference on either 9.5 or 9.6. You can check it out here if you want: http://dev-rizzo.dw-demo.com The page is at the bottom: Data lists | Test (ID 186). It used a template called DownloadDataList.cshtml to match an item type called DownloadDataList. The template calls a component to get the CSV and then streams it back to the browser. It works with GZip off under Settings, but when I turn it on I get a zip-ish file, regardless of the content type setting...

 
Nicolai Pedersen
Reply

Hm, can see that the conditional for that is no longer existing. Just re-implemented it.

Anyways it should be possible to send csv files as gzip. Do you maybe have a gzip directive in web.config for the response type that ends up with double gzip?

BR Nicolai

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
This post has been marked as an answer

The only GZip related stuff in web.config is whatever comes from the standard application's config file. I took it out but it made no difference.

I worked around it for now by setting the Response.Filter to null after it's been set in PageView:

response.Filter = null; // Clear out Dynamicweb;'s GZip compression

Thanks!

Votes for this answer: 1

 

You must be logged in to post in the forum