Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC compression options in IIS6

Tags:

For now I'm stuck with IIS6 for ASP.NET-MVC (as in I cant upgrade to Server 2008 yet). It doesnt seem to know that my RESTful URLS are dynamic files and isn't compressing them.

All my old .aspx files are compressed (as seen in Fiddler), but not the '/products/1001' type URLS.

Is there any way to get IIS6 to compress my ActionResults in IIS6 without using something like an ActionFilter for compression.

I'm assuming IIS7 is clever enough to know they're dynamic right.

Bonus points if you can tell me how IIS6 even knows which files are dynamic in the first place!

like image 577
Simon_Weaver Avatar asked Mar 16 '09 06:03

Simon_Weaver


1 Answers

As HTTP compression for ASP.NET usually has been implemented using HttpModules since version 1.0, and HttpModules still belong to the ASP.NET request pipeline used by the MVC framework, you can still use a HttpModule to inject a GZIP or deflate response filter.

Here you can find a very nice, open-source, ready to ship implementation: HttpCompress by Ben Lowery (download at Google Code)

You just have to add a reference to the DLL, and add a few lines to your web.config. It already handles very exotic and rare cases and exceptions. You can add exclusions to your web.config, not based on file extensions (like in IIS6), but on mime type, which is probably exactly what you need.

I should add that I have actually running a ASP.NET MVC website on IIS6 using this library, so I can confirm that this works in practice.

like image 106
realMarkusSchmidt Avatar answered Sep 28 '22 06:09

realMarkusSchmidt