This post originated from an RSS feed registered with .NET Buzz
by Brad Wilson.
Original Post: IIS 6 Compression and ASP.NET
Feed Title: The .NET Guy
Feed URL: /error.aspx?aspxerrorpath=/dotnetguy/Rss.aspx
Feed Description: A personal blog about technology in general, .NET in specific, and when all else fails, the real world.
I set off on a task this morning of getting compression working on a Windows Server 2003 box running our ASP.NET application. I'm writing about it, so it must have required some non-trivial work, right? Right.
If you follow these directions from Microsoft, you'll have compression enabled, but still non-functional. There are two pieces to the puzzle that they don't share with you.
1. Allow the compression ISAPI to run
IIS 6's new security system prohibits ISAPI DLLs from running by default, so you need to tell IIS 6 that it's okay to let the compression ISAPI DLL run.
Open the IIS admin tool, drill into your server, and right-click on "Web Service Extensions". Choose "Add a new web service extension". For the extension name, use whatever you want to identify it in the list (I used "HTTP Compression"). You need to add a single required file, which is \Windows\System32\inetsrv\gzip.dll, the ISAPI responsible for doing gzip and deflate compression. Check the "Set extension status to allowed", then click OK. You should have a new web service extension in your list called "HTTP Compression" (or whatever you named it), and it should have a status of "Allowed".
2. Select compressible content
IIS 6's compression system only compresses a very limited set of content. You need to enable compression for the appropriate file extensions (specifically, .aspx files for your ASP.NET pages, and perhaps any static content you want compressed as well).
You're going to edit the Metabase. To do this, you first need to shut down IIS. In the IIS admin tool, right click on your server name in the left panel, and choose All Tasks -> Restart IIS. On the restart dialog, choose "Stop internet services" and click OK. When IIS is shut down, you'll need to edit \Windows\System32\inetsrv\MetaBase.xml (make a backup first!). Search for "IIsCompressionScheme". There will be two XML elements, one for deflate and one for gzip. Both elements have properties called HcFileExtensions and HcScriptFileExtensions. These contain a space-delimited list of file extension for compressible content. At a bare minimum, you'll need to add aspx to the HcScriptFileExtensions list. Note that if the properties are left blank, then all content, regardless of file extension, will be compressed.