tags:

views:

519

answers:

2

this seems so silly - i must be missing something obvious. I have the following code (just as a test):

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<script runat="server">
    void page_load(object o, EventArgs e)
    {
        Response.Write(new string(' ', 255));
        Response.Flush();
        for (int i = 0; i < 10; i++)
        {
            Response.Write(i + "<BR>");
            Response.Flush();
            System.Threading.Thread.Sleep(500);
        }

    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        main div
    </div>
    </form>
</body>
</html>

when i test this locally (vista x64, cassini), i get the desired output.. 1, then 2, then 3, etc are all sent non-buffered to the browser. when i try this on the dev server (2003, iis6) it just buffers it all and sends it all at once. is there something obvious i'm missing?? I've also tried putting buffer=false at the top but that also doesn't change this behaviour.

to further clarify, i've done a test with fiddler to compare two servers. the first server is a local server on the LAN, the second is a public server. fiddler found no discernible difference between the two, except for the host name. the LAN server did not write out the response until the page had finished loading, the public server wrote the response as it happened. i can also confirm this behaviour happens in both firefox and ie.

+2  A: 

Try this in Page_Load:

Response.BufferOutput = false;

Also get a copy of Fiddler and watch your HTTP conversation to make sure your page is not cached.

Dave Markle
thanks dave - will try fiddler now. Forgot to mention I also tried BufferOutput = false but that also didn't make a difference.
benpage
definitely not being cached.
benpage
A: 

you can also programmatically direct the browser to ditch the cache for the selected page (though it's up to the browser to actually honor your directive).

Public Sub KillCache()
    Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache)
    Response.Cache.SetExpires(New Date(1900, 1, 1))
    Response.Cache.SetMaxAge(New TimeSpan(0, 0, 5))   '// 5 SECONDS'
    Response.Cache.SetNoServerCaching()
    Response.Cache.SetNoStore()
    Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches)
End Sub
eidylon
the page is definitely not being cached. this has something more to do with the fact i'm running it on a machine within the intranet
benpage