I’ve been investigating this problem for a couple of days and hope that this post would save others some grief. Here’s the situation: 2 web servers, same configuration (at least that’s what it seemed), and on one server I can successfully export data to a downloadable CSV file but on the other server the CSV export downloads as an ASPX page instead of the CSV file. Seems strange when all configurations on the server is supposedly the same. After several unsuccessful comparisons of configuration settings …etc I’ve gone down to the level of analyzing the HTTP traffic from/to both servers and comparing the differences and that’s when one difference became apparent. On one server I can see that the HTTP traffic has been compressed and on the other that wasn’t the case. Strange …eh. For both sites the settings below were the same, which lead me think that probably the command line HTTP Compression settings were not configured correctly on one of the servers. So after reconfiguring compression on both servers the issue of exporting the CSV file was now occurring on both servers.

IIS6Compression

So the only possible way to resolve this problem was by disabling compression and given this was not desirable at a global site level the only other option left was to turn off compression for a specific folder. As a result I’ve moved the CSV export ASPX page into its own folder and disabled compression there and there you go that was the solution!!

To find out more about enabling HTTP Compression check the Enabling HTTP Compression (IIS 6.0) page.

At the bottom of the page there’s the reference below on enabling compression on a directory specific basis.

adsutil set w3svc/1/root/Home/StyleSheets/DoStaticCompression false

The number 1 shown above represents you’re site ID, for the default website the value is one, for other sites the value will be different. To obtain the Site ID of your site in IIS6 follow Chris Crowe‘s blog post IIS Website Identifiers which provides detailed info on how to obtain your Site ID.

Hope this helps.