asp.net mvc - Supporting custom compression algorithm for IIS served content -


i have bunch of internet devices communicate mvc app on iis 7.5. i'm using built-in dynamic transparent compression (gzip/deflate).

i'd able support different compression algorithm, lot better gzip (7zip) content i'm sending/receiving.

in other words, on client add header: accepts: gzip, deflate, 7zip (or similar), , server recognize this, , apply best choice when sending content.

what's best way go hooking together? (i know how implement actual 7zip encode/decode aspect)

thanks.

on server side, can compress responses using httpmodule. httpmodule similar global.asax in exposes request , response lifecycle events beginrequest, releaserequeststate, , endrequest. can alter contents of response handling appropriate event , changing output stream. typically alter response attaching output filter. example, the blowery httpcompress module(no longer updated) attaches compression filters in releaserequeststate or presendrequestheaders events:

http://code.google.com/p/httpcompress/source/browse/trunk/httpcompress/httpmodule.cs

in addition compressing content, you'll need set content-encoding header. more recent(though beta) example, check out rich crane's wicked compression module. codeproject has example module.

keep in mind, compressing httpmodule not play nice if iis set compress @ server level. in addition, prepared few corner cases if you're using ajax or .axd handlers. these requests may not work expect or may not pass through module without explicitly wiring them in.

on client side, you'll need pass custom accept-encoding token each request. avoid compressing on server if token isn't set. if add clients in future, may not clear why they're failing if responses compressed custom compression.

i'm not sure how clients making requests, http request/response pipelines allow tap response stream in similar way server. before response sent renderer, check custom content-encoding token. if it's present, run decompression routine. if not, pass response through unaltered.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -