I'm having a really odd situation where I am chaining both a whitespace removal and Gzip compression filters to Response.Filter. Essentially giving me both an optimised and compressed output when necessary.
However, I'm having a problem where this is working perfectly fine on 2 servers and not so on 2 others. The other 2 are responding with a blank output stream and no errors, whereas the others are working fully.
As far as I can tell, each server has the exact same IIS setup. Infact 2 of the machines are virtual copies of each other, and it still works on one and not the other.
If I switch the filter to just GZIP or just whitespace removal only, everything works on all servers. This only happens when I chain them together.
context.Response.Filter = new Common.WhitespaceFilter(new GZipStream(context.Response.Filter, CompressionMode.Compress));
I'm struggling for ideas on why this is happening and what else I can try. I'm really hoping that someone has seen or heard of this before and knows what it might be?
I think I have fixed the issue. It is strange that some servers worked and some didn't, but what I was missing was that my WhiteSpace Filter was not allowing the compression stream to Close or Flush.
All I needed to do was to add the override methods of Close and Flush and ensure that that encapsulated compression stream was closed at the same time as the base.
public override void Close()
{ outputStream.Close(); base.Close(); }
public override void Flush()
{ outputStream.Flush(); base.Flush(); }
Seems so simple now, but took all weekend to work that out! The part of development we all hate!
HDev
Member
15 Points
5 Posts
Chaining Response.Filter streams results in blank output on some servers
Nov 10, 2012 11:18 PM|LINK
I'm having a really odd situation where I am chaining both a whitespace removal and Gzip compression filters to Response.Filter. Essentially giving me both an optimised and compressed output when necessary.
However, I'm having a problem where this is working perfectly fine on 2 servers and not so on 2 others. The other 2 are responding with a blank output stream and no errors, whereas the others are working fully.
As far as I can tell, each server has the exact same IIS setup. Infact 2 of the machines are virtual copies of each other, and it still works on one and not the other.
If I switch the filter to just GZIP or just whitespace removal only, everything works on all servers. This only happens when I chain them together.
I'm struggling for ideas on why this is happening and what else I can try. I'm really hoping that someone has seen or heard of this before and knows what it might be?
HDev
Member
15 Points
5 Posts
Re: Chaining Response.Filter streams results in blank output on some servers
Nov 11, 2012 08:40 PM|LINK
I think I have fixed the issue. It is strange that some servers worked and some didn't, but what I was missing was that my WhiteSpace Filter was not allowing the compression stream to Close or Flush.
All I needed to do was to add the override methods of Close and Flush and ensure that that encapsulated compression stream was closed at the same time as the base.
public override void Close() { outputStream.Close(); base.Close(); } public override void Flush() { outputStream.Flush(); base.Flush(); }Seems so simple now, but took all weekend to work that out! The part of development we all hate!