According to this blog post , DynamicCompressionModule, which is responsible for handling dynamic compression, starts at the ReleaseRequestState stage (which happens before UpdateRequestCache, when the page is stored in the output cache). Therefore:
- if you want to process the response before performing dynamic compression, then you should put your filtering code in the HttpModule, which is connected to the PostRequestHandlerExecute event;
- if you want to handle response caching, it does, but after compression you have to put your filter code in the HttpModule, which fires the PostReleaseRequestState event.
Here is an example of how to do this:
public class SampleModule : IHttpModule { public void Dispose() { return; } public void Init(HttpApplication context) { context.PostRequestHandlerExecute += new EventHandler(App_OnPostRequestHandlerExecute); context.PostReleaseRequestState += new EventHandler(App_OnPostReleaseRequestState); } private void App_OnPostRequestHandlerExecute(object sender, EventArgs e) { HttpApplication app = (HttpApplication)sender; HttpResponse response = app.Context.Response; response.Write("<b>Modified!</b>"); } private void App_OnPostReleaseRequestState(object sender, EventArgs e) { HttpApplication app = (HttpApplication)sender; HttpResponse response = app.Context.Response;
And then register your module using the web.config file:
<add name="SampleModule" type="My.ModuleNamespace.SampleModule" />
AlexB
source share