I wrote the HttpModule, which I use to intercept, calls the WebResource.axd handler, so I can do some post processing on javascript.
The module wraps the Response.Filter stream to execute its processing and writes it to the base stream.
The problem is that the script is not returning to the browser.
So, as a really simple example that just acts like a pass, the module looks like this:
public class ResourceModule : IHttpModule { public void Dispose() { } public void Init(HttpApplication context) { context.PostRequestHandlerExecute += new EventHandler(context_PostRequestHandlerExecute); } void context_PostRequestHandlerExecute(object sender, EventArgs e) { HttpApplication context = sender as HttpApplication; if (context.Request.Url.ToString().Contains("WebResource.axd")) { context.Response.Filter = new ResourceFilter(context.Response.Filter); } } }
and ResourceFilter, which simply outputs what it receives, looks like this:
public class ResourceFilter : MemoryStream { private Stream inner; public ResourceFilter(Stream inner) { this.inner = inner; } public override void Write(byte[] buffer, int offset, int count) { inner.Write(buffer, offset, count); } }
I can attach and see how the module and filter are called, but when I look at the URL of WebResource.axd, I get nothing.
I used this template to implement modules that do processing on aspx pages, and they work very well. There seems to be something about interacting with WebResource.axd that is preventing this from working.
Steve jackson
source share