ASP Dot Net compression using http handlersThis is a featured page

Implementing an output filter for gzip compression for custom asp.net applications may at first seem like a daunting task. However in reality this is far simpler than it looks. The ideal mechanism for achieving this is by means of an HTTP handler. HTTP handlers can be attached at will into the processing pipeline either for an entire dot net web application, a subfolder of one, or even just for a single page of an application. This fine grain control can by specified by the http handlers section of the web.config file. The http handler implementation is comprised of two parts. First we must check if the web browser supports GZIP compression. Secondly if gzip compression is supported then we need to attach a gzip compressed IO stream as an output filter. Checking if the web browser supports GZIP compression is done by inspecting the web request headers to see if it contains an AcceptEncoding = "gzip" or AcceptEncoding = ”deflate” header. If this header is present this means that the browser is capable of receiving gzip compressed data. If compression is supported then we proceed to attach a GZIP compressed IO stream. Although the dot net framework itself provides GZIP compressed IO stream classes these are not as performant as we would like them to be. However we do not need to write our own either. Fortunately for us the ICSharpCode project provides a high performance, high compression implementation in their SharpZipLib dll. This is an open source component which can be used freely in both opensource as well as closed source commercial projects. At this stage all we need to do is to create an instance of the GZIP compression IO stream class and set it as an output filter for the active response object. Beyond this all else is taken care of by IIS itself.
asp dot net compression
programming .net

For a free implementation which you can download as well as follow the source code please take a look at asp dot net compression. click here for more asp dot net development resources


No user avatar
aspdotnetcompr
Latest page update: made by aspdotnetcompr , Dec 8 2009, 7:32 AM EST (about this update About This Update aspdotnetcompr Edited by aspdotnetcompr

347 words added

view changes

- complete history)
More Info: links to this page
There are no threads for this page.  Be the first to start a new thread.

Related Content

  (what's this?Related ContentThanks to keyword tags, links to related pages and threads are added to the bottom of your pages. Up to 15 links are shown, determined by matching tags and by how recently the content was updated; keeping the most current at the top. Share your feedback on Wetpaint Central.)