Pierre Greborio.NET

Talking about .NET world

HttpResponse Flush

Sometimes I need to flush the content of the buffer before the end of my PageLoad. The documentation says "Forces all currently buffered output to be sent to the client." That is not really true.

If the buffer doesn't contains at least 257 bytes (calculated empirically on my Windows XP SP2), the buffer will not be sent to the client. Is it a documentation error or code error ?

Posted: Jan 13 2005, 12:53 AM by PierreG | with 5 comment(s)
Filed under:

Comments

Jeff Atwood said:

YES! If true, this explains a behavior I experienced with .Flush() as well. Eg, "why aren't my flushes flushing?"

And get your minds out of the gutter.
# January 12, 2005 7:55 PM

MartinJ said:

Part of the reason might have to do with the underlying protocol. TCP doesn't really like handling blocks of data smaller than 256 bytes. So, the TCP stack might be holding onto the bytes until it deems it necessary.
# January 13, 2005 12:05 AM

Aviv Raff said:

Another reason that might cause the problem is the Internet Explorer's mime-type detection system, which takes the first 256 bytes of the page to automatically detect which mime-type the page uses.
So this might be a browser bug. Have you tried it with other browsers?
# January 13, 2005 1:27 AM

Pierre Greborio said:

Yes Aviv, good point. The problem is IE. With Firefox 1.0 the buffer content is shown.

# January 13, 2005 4:35 AM

rocco said:

Hello, I've a similar problem: my code works fine with some versions of IE (IE5.5,IE7.

IE6 v.6.0.2900.2180.xpsp_sp2_gdr.061219-0316) but doesn't correctly flushes the data with some others (IE 6 v.6.0.2900.2180.xpsp_sp2_rtm.

040803-2158).

The strange is that I have the problem only in my PRODUCTION Environment, but not in the TEST environment (with the same identical SERVER configuration): it work fine with all IE versions!

Can you help me?

Thank you

# July 30, 2007 4:15 AM