ASP.NET 2.0: Whitespace Removal HTTP Module

    November 10, 2006

I’ve written about whitespace removal before, but I think this is the best solution so far.

It is a plug n’ play HTTP module that works simply by adding the class to the App_Code folder.

It uses regular expressions to identify and remove the unnecessary whitespace from the current .aspx web page.

The overhead from this module is almost too insignificant to even measure.


Download the WhitespaceModule.cs below and put it in the App_Code folder. Then add this to the web.config.


   <add type="WhitespaceModule" name="WhitespaceModule"/>


The cool thing about HTTP modules like this is that you can add them to any ASP.NET project without changing existing code.

You can do even more to reduce the weight of your webpages by using a HTTP compression module that can be implememted the same way as this module.

Download (0,97 KB)


Add to | Digg | Reddit | Furl

Bookmark WebProNews:

Mads Kristensen currently works as a Senior Developer at Traceworks located
in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in
2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and
web services in his daily work as well. A true .NET developer with great passion for the simple solution.