HTTP Compression via HttpModule

I've talked about HTTP compression in IIS 6.0, and HTTP compression using Net.WebClient, but what about deploying ASP.NET websites to servers you don't control, eg, third party hosts? How can we enable compression in that scenario?

This is a companion discussion topic for the original blog entry at:

Hi Jeff,

What rev of ASP.NET are you running on? Sadly, there are some serious problems with how filters work with regards to Response.End in most of the shipping editions of ASP.NET. The filter design feels like a bit of an after-thought and doesn’t work well in anything but the most basic situations. :frowning:

–ben (author of httpcompress)

I would go one further in order to catch Response.Redirect() also…

void CompressContent(object sender, EventArgs e)
HttpApplication app = (HttpApplication)sender;

// Only compress normal responses.
if (app.Context.Response.StatusCode != 200 || app.Server.GetLastError() != null)

This results in only compressing normal responses which I think is a reasonable compromise.


nice topic i never thought about this before

I want to know how i can implement a http compression?

Wow, the programmer did a good job. By the first test the tool does compress the request. But the tool does compress my javascript on my page,too. So my page doesn’t work any more. Navigation is impossible now.
Are the any other tools which can solve this problem?