Summary

Windows Server 2003 is, without a doubt, the best platform for running ASP.NET available. Turning on the compression built into IIS6 allows you to save valuable bandwidth with your ASP.NET-based web sites.

Compressible Content

If you follow these directions from Microsoft, you'll have compression enabled, but still non-functional for ASP.NET. The reason is that the ASP.NET file extension (.aspx) is not set as a valid compressible file extension.

To make this change, you're going to need to edit the Metabase. Edit \Windows\System32\inetsrv\MetaBase.xml with your favorite text editor. 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.

Now fire up a tool like YATT and watch the HTTP stream as you make a request. You should see in the response headers that indicate that the content is being compressed (and it should look like garbage, rather than HTML, since it's compressed).

What if it Still Doesn't Work?

I've had a rather unique problem that others can't seem to replicate. I'm going to document it here, in case anybody else runs into a problem where it seems like compression should be working, but isn't. Don't do this unless you find compression isn't working even after following the steps above.

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".

About the Author

Brad Wilson is a .NET technology consultant and a frequent contributor to .NET related mailing lists. When not writing at his web log, he spends much of his time looking for inventive ways to break ASP.NET and bend it to his will. :)

Brad lives in beautiful Parker, Colorado. He is an avid game player, including poker, backgammon, cribbage, and Go.

If you have any questions or concerns about his articles, you may contact Brad here.

Brad Wilson