Response.flush()

Discussion in 'ASP General' started by Jon Spivey, Jan 20, 2004.

  1. Jon Spivey

    Jon Spivey Guest

    Experimenting with response.flush() but can't seem to get it to work. This
    code
    <%
    response.write "<p>started</p>"
    response.flush()
    for i = 1 to 10000000
    i = i +1
    next
    response.write "<p>ended</p>"
    %>
    Should it not write started to the screen straight away and then a couple of
    seconds later, when the loops finished, write ended? When I test on XP Pro
    and Windows Server 2003 the flush doesnt happen - the page takes a couple of
    seconds to load up and then writes started ended at the same time.

    Also found this article on aspfaq
    http://www.aspfaq.com/show.asp?id=2498
    but the response.flush() doesn't happen with that sample code either

    Any ideas?

    Jon
     
    Jon Spivey, Jan 20, 2004
    #1
    1. Advertising

  2. Jon Spivey

    Ray at Guest

    I believe there's a thing about certain browsers, i.e. IE, where they won't
    display anything until the response they've received is of a minumum number
    of bytes. I don't know what the minimum is, though. You could try adding a
    line like so above the <p>started</p> line:

    response.write "<!-- " & String(200, "x") & " -->"

    BTW, do you know that your for-loop is essentially doing a Step 2? You
    don't have to increment the looping variable.

    Ray at work

    "Jon Spivey" <> wrote in message
    news:...
    > Experimenting with response.flush() but can't seem to get it to work. This
    > code
    > <%
    > response.write "<p>started</p>"
    > response.flush()
    > for i = 1 to 10000000
    > i = i +1
    > next
    > response.write "<p>ended</p>"
    > %>
    > Should it not write started to the screen straight away and then a couple

    of
    > seconds later, when the loops finished, write ended? When I test on XP Pro
    > and Windows Server 2003 the flush doesnt happen - the page takes a couple

    of
    > seconds to load up and then writes started ended at the same time.
    >
    > Also found this article on aspfaq
    > http://www.aspfaq.com/show.asp?id=2498
    > but the response.flush() doesn't happen with that sample code either
    >
    > Any ideas?
    >
    > Jon
    >
    >
     
    Ray at, Jan 20, 2004
    #2
    1. Advertising

  3. Jon Spivey

    Jon Spivey Guest

    Hi,
    thanks for the reply I tried adding some more text to my little sample and
    guess what - the flush happened on my dev machine XP Pro/IIS5.1 but not my
    web server IIS6/Windows Server 2003. My problem is I'm working on this site
    www.bookhead.co.uk if you click any of the book links the next page pulls
    the book details from sql server 2000 then uses xmlhttp to get prices for
    the book from 11 retailers. The db lookup is quick, the xmlhttp part can
    take about 10 seconds - so I put response.flush() after the db lookup, the
    flush isn't happening with the result that the page takes about 10 seconds
    to display - obviously unacceptable so I need to fix this

    I can't post up the code for the page I'm working on its ~150 lines is there
    something you can think of that would stop response.flush() from happening?
    I've also written my host to see if they have any ideas

    Jon

    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:...
    > I believe there's a thing about certain browsers, i.e. IE, where they

    won't
    > display anything until the response they've received is of a minumum

    number
    > of bytes. I don't know what the minimum is, though. You could try adding

    a
    > line like so above the <p>started</p> line:
    >
    > response.write "<!-- " & String(200, "x") & " -->"
    >
    > BTW, do you know that your for-loop is essentially doing a Step 2? You
    > don't have to increment the looping variable.
    >
    > Ray at work
    >
    > "Jon Spivey" <> wrote in message
    > news:...
    > > Experimenting with response.flush() but can't seem to get it to work.

    This
    > > code
    > > <%
    > > response.write "<p>started</p>"
    > > response.flush()
    > > for i = 1 to 10000000
    > > i = i +1
    > > next
    > > response.write "<p>ended</p>"
    > > %>
    > > Should it not write started to the screen straight away and then a

    couple
    > of
    > > seconds later, when the loops finished, write ended? When I test on XP

    Pro
    > > and Windows Server 2003 the flush doesnt happen - the page takes a

    couple
    > of
    > > seconds to load up and then writes started ended at the same time.
    > >
    > > Also found this article on aspfaq
    > > http://www.aspfaq.com/show.asp?id=2498
    > > but the response.flush() doesn't happen with that sample code either
    > >
    > > Any ideas?
    > >
    > > Jon
    > >
    > >

    >
    >
     
    Jon Spivey, Jan 20, 2004
    #3
  4. Your code work perfectly well on my XP Pro workstation, with the web server
    being on the same machine.

    Maybe you are separated from you Windows Server with a firewall or a proxy
    who is buffering the whole thing. Your LAN may also be involved.

    I suggest that you install the web server directly on you station and then
    making somes tests with that configuration.

    S. L.


    "Jon Spivey" <> wrote in message
    news:...
    > Experimenting with response.flush() but can't seem to get it to work. This
    > code
    > <%
    > response.write "<p>started</p>"
    > response.flush()
    > for i = 1 to 10000000
    > i = i +1
    > next
    > response.write "<p>ended</p>"
    > %>
    > Should it not write started to the screen straight away and then a couple

    of
    > seconds later, when the loops finished, write ended? When I test on XP Pro
    > and Windows Server 2003 the flush doesnt happen - the page takes a couple

    of
    > seconds to load up and then writes started ended at the same time.
    >
    > Also found this article on aspfaq
    > http://www.aspfaq.com/show.asp?id=2498
    > but the response.flush() doesn't happen with that sample code either
    >
    > Any ideas?
    >
    > Jon
    >
    >
     
    Sylvain Lafontaine, Jan 20, 2004
    #4
  5. Jon Spivey

    Ray at Guest

    I've run into this problem before and I've yet to find a definitive answer.
    I believe that it's a browser issue, actually. When I loaded your code on
    my W2K server, it did not [seem to] flush just as you described. Then I
    added the long comment and it worked. Then I restored the code back to
    exactly what you posted and it flushed that time. Inconsistencies do not
    make sense. I believe that if you quickly do a view-source while you're
    waiting for your flush, you may actually see the <p>started</p> in there.

    Ray at work

    "Jon Spivey" <> wrote in message
    news:%23Os%...
    > Hi,
    > thanks for the reply I tried adding some more text to my little sample and
    > guess what - the flush happened on my dev machine XP Pro/IIS5.1 but not my
    > web server IIS6/Windows Server 2003. My problem is I'm working on this

    site
    > www.bookhead.co.uk if you click any of the book links the next page pulls
    > the book details from sql server 2000 then uses xmlhttp to get prices for
    > the book from 11 retailers. The db lookup is quick, the xmlhttp part can
    > take about 10 seconds - so I put response.flush() after the db lookup,

    the
    > flush isn't happening with the result that the page takes about 10 seconds
    > to display - obviously unacceptable so I need to fix this
    >
    > I can't post up the code for the page I'm working on its ~150 lines is

    there
    > something you can think of that would stop response.flush() from

    happening?
    > I've also written my host to see if they have any ideas
    >
    > Jon
    >
    > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    > news:...
    > > I believe there's a thing about certain browsers, i.e. IE, where they

    > won't
    > > display anything until the response they've received is of a minumum

    > number
    > > of bytes. I don't know what the minimum is, though. You could try

    adding
    > a
    > > line like so above the <p>started</p> line:
    > >
    > > response.write "<!-- " & String(200, "x") & " -->"
    > >
    > > BTW, do you know that your for-loop is essentially doing a Step 2? You
    > > don't have to increment the looping variable.
    > >
    > > Ray at work
    > >
    > > "Jon Spivey" <> wrote in message
    > > news:...
    > > > Experimenting with response.flush() but can't seem to get it to work.

    > This
    > > > code
    > > > <%
    > > > response.write "<p>started</p>"
    > > > response.flush()
    > > > for i = 1 to 10000000
    > > > i = i +1
    > > > next
    > > > response.write "<p>ended</p>"
    > > > %>
    > > > Should it not write started to the screen straight away and then a

    > couple
    > > of
    > > > seconds later, when the loops finished, write ended? When I test on XP

    > Pro
    > > > and Windows Server 2003 the flush doesnt happen - the page takes a

    > couple
    > > of
    > > > seconds to load up and then writes started ended at the same time.
    > > >
    > > > Also found this article on aspfaq
    > > > http://www.aspfaq.com/show.asp?id=2498
    > > > but the response.flush() doesn't happen with that sample code either
    > > >
    > > > Any ideas?
    > > >
    > > > Jon
    > > >
    > > >

    > >
    > >

    >
    >
     
    Ray at, Jan 20, 2004
    #5
  6. Jon Spivey

    Jon Spivey Guest

    I'm working on my laptop at the moment IIS on the same machine - no lan
    firewall proxy etc. The real issue here is the site I'm working on that I
    posted up earlier - not being able to get response.flush working is ruining
    the site.

    Just for the heck of it I uploaded Ray's code with the long string here
    http://www.roksteady.net/flushed.asp

    The flush works on my dev machine but is not happening on the web server -
    running IIS6 Windows Server 2003. Also tested in Netscape 7 and firebird
    just to be sure it isn't an IE thing. I wonder if response.flush() is
    somewhat flakey or there is something I'm missing here. Either way I need to
    get to the bottom of this

    Jon

    "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
    wrote in message news:...
    > Your code work perfectly well on my XP Pro workstation, with the web

    server
    > being on the same machine.
    >
    > Maybe you are separated from you Windows Server with a firewall or a

    proxy
    > who is buffering the whole thing. Your LAN may also be involved.
    >
    > I suggest that you install the web server directly on you station and then
    > making somes tests with that configuration.
    >
    > S. L.
    >
    >
    > "Jon Spivey" <> wrote in message
    > news:...
    > > Experimenting with response.flush() but can't seem to get it to work.

    This
    > > code
    > > <%
    > > response.write "<p>started</p>"
    > > response.flush()
    > > for i = 1 to 10000000
    > > i = i +1
    > > next
    > > response.write "<p>ended</p>"
    > > %>
    > > Should it not write started to the screen straight away and then a

    couple
    > of
    > > seconds later, when the loops finished, write ended? When I test on XP

    Pro
    > > and Windows Server 2003 the flush doesnt happen - the page takes a

    couple
    > of
    > > seconds to load up and then writes started ended at the same time.
    > >
    > > Also found this article on aspfaq
    > > http://www.aspfaq.com/show.asp?id=2498
    > > but the response.flush() doesn't happen with that sample code either
    > >
    > > Any ideas?
    > >
    > > Jon
    > >
    > >

    >
    >
     
    Jon Spivey, Jan 20, 2004
    #6
  7. Jon Spivey

    Jon Spivey Guest

    As far as I can see this must be a server issue - from my testing the exact
    same pages that refuse to flush on my IIS6 web server flush perfectly on 2
    IIS5.1 computers here. Still trying to get to the bottom of this but running
    out of ideas.....

    Jon

    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:...
    > I've run into this problem before and I've yet to find a definitive

    answer.
    > I believe that it's a browser issue, actually. When I loaded your code on
    > my W2K server, it did not [seem to] flush just as you described. Then I
    > added the long comment and it worked. Then I restored the code back to
    > exactly what you posted and it flushed that time. Inconsistencies do not
    > make sense. I believe that if you quickly do a view-source while you're
    > waiting for your flush, you may actually see the <p>started</p> in there.
    >
    > Ray at work
    >
    > "Jon Spivey" <> wrote in message
    > news:%23Os%...
    > > Hi,
    > > thanks for the reply I tried adding some more text to my little sample

    and
    > > guess what - the flush happened on my dev machine XP Pro/IIS5.1 but not

    my
    > > web server IIS6/Windows Server 2003. My problem is I'm working on this

    > site
    > > www.bookhead.co.uk if you click any of the book links the next page

    pulls
    > > the book details from sql server 2000 then uses xmlhttp to get prices

    for
    > > the book from 11 retailers. The db lookup is quick, the xmlhttp part can
    > > take about 10 seconds - so I put response.flush() after the db lookup,

    > the
    > > flush isn't happening with the result that the page takes about 10

    seconds
    > > to display - obviously unacceptable so I need to fix this
    > >
    > > I can't post up the code for the page I'm working on its ~150 lines is

    > there
    > > something you can think of that would stop response.flush() from

    > happening?
    > > I've also written my host to see if they have any ideas
    > >
    > > Jon
    > >
    > > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    > > news:...
    > > > I believe there's a thing about certain browsers, i.e. IE, where they

    > > won't
    > > > display anything until the response they've received is of a minumum

    > > number
    > > > of bytes. I don't know what the minimum is, though. You could try

    > adding
    > > a
    > > > line like so above the <p>started</p> line:
    > > >
    > > > response.write "<!-- " & String(200, "x") & " -->"
    > > >
    > > > BTW, do you know that your for-loop is essentially doing a Step 2?

    You
    > > > don't have to increment the looping variable.
    > > >
    > > > Ray at work
    > > >
    > > > "Jon Spivey" <> wrote in message
    > > > news:...
    > > > > Experimenting with response.flush() but can't seem to get it to

    work.
    > > This
    > > > > code
    > > > > <%
    > > > > response.write "<p>started</p>"
    > > > > response.flush()
    > > > > for i = 1 to 10000000
    > > > > i = i +1
    > > > > next
    > > > > response.write "<p>ended</p>"
    > > > > %>
    > > > > Should it not write started to the screen straight away and then a

    > > couple
    > > > of
    > > > > seconds later, when the loops finished, write ended? When I test on

    XP
    > > Pro
    > > > > and Windows Server 2003 the flush doesnt happen - the page takes a

    > > couple
    > > > of
    > > > > seconds to load up and then writes started ended at the same time.
    > > > >
    > > > > Also found this article on aspfaq
    > > > > http://www.aspfaq.com/show.asp?id=2498
    > > > > but the response.flush() doesn't happen with that sample code either
    > > > >
    > > > > Any ideas?
    > > > >
    > > > > Jon
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Jon Spivey, Jan 20, 2004
    #7
  8. Jon Spivey

    Jon Spivey Guest

    Did some more searching and found the answer - it seems IIS6 has some
    performance issues with response.flush with a fix due in the first SP
    http://groups.google.com/groups?hl=...q=response.flush+iis6&ie=UTF-8&oe=UTF-8&hl=en

    Solved my own issue with a very nasty hack
    do db lookup then stop
    javascript to redirect to the same page
    finish processing page
    This accomplishes almost the same thing as response.flush() but we shouldn't
    have to do things like this on supposedly "better" products

    Jon

    "Jon Spivey" <> wrote in message
    news:%...
    > As far as I can see this must be a server issue - from my testing the

    exact
    > same pages that refuse to flush on my IIS6 web server flush perfectly on 2
    > IIS5.1 computers here. Still trying to get to the bottom of this but

    running
    > out of ideas.....
    >
    > Jon
    >
    > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    > news:...
    > > I've run into this problem before and I've yet to find a definitive

    > answer.
    > > I believe that it's a browser issue, actually. When I loaded your code

    on
    > > my W2K server, it did not [seem to] flush just as you described. Then I
    > > added the long comment and it worked. Then I restored the code back to
    > > exactly what you posted and it flushed that time. Inconsistencies do

    not
    > > make sense. I believe that if you quickly do a view-source while you're
    > > waiting for your flush, you may actually see the <p>started</p> in

    there.
    > >
    > > Ray at work
    > >
    > > "Jon Spivey" <> wrote in message
    > > news:%23Os%...
    > > > Hi,
    > > > thanks for the reply I tried adding some more text to my little sample

    > and
    > > > guess what - the flush happened on my dev machine XP Pro/IIS5.1 but

    not
    > my
    > > > web server IIS6/Windows Server 2003. My problem is I'm working on this

    > > site
    > > > www.bookhead.co.uk if you click any of the book links the next page

    > pulls
    > > > the book details from sql server 2000 then uses xmlhttp to get prices

    > for
    > > > the book from 11 retailers. The db lookup is quick, the xmlhttp part

    can
    > > > take about 10 seconds - so I put response.flush() after the db

    lookup,
    > > the
    > > > flush isn't happening with the result that the page takes about 10

    > seconds
    > > > to display - obviously unacceptable so I need to fix this
    > > >
    > > > I can't post up the code for the page I'm working on its ~150 lines is

    > > there
    > > > something you can think of that would stop response.flush() from

    > > happening?
    > > > I've also written my host to see if they have any ideas
    > > >
    > > > Jon
    > > >
    > > > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in

    message
    > > > news:...
    > > > > I believe there's a thing about certain browsers, i.e. IE, where

    they
    > > > won't
    > > > > display anything until the response they've received is of a minumum
    > > > number
    > > > > of bytes. I don't know what the minimum is, though. You could try

    > > adding
    > > > a
    > > > > line like so above the <p>started</p> line:
    > > > >
    > > > > response.write "<!-- " & String(200, "x") & " -->"
    > > > >
    > > > > BTW, do you know that your for-loop is essentially doing a Step 2?

    > You
    > > > > don't have to increment the looping variable.
    > > > >
    > > > > Ray at work
    > > > >
    > > > > "Jon Spivey" <> wrote in message
    > > > > news:...
    > > > > > Experimenting with response.flush() but can't seem to get it to

    > work.
    > > > This
    > > > > > code
    > > > > > <%
    > > > > > response.write "<p>started</p>"
    > > > > > response.flush()
    > > > > > for i = 1 to 10000000
    > > > > > i = i +1
    > > > > > next
    > > > > > response.write "<p>ended</p>"
    > > > > > %>
    > > > > > Should it not write started to the screen straight away and then a
    > > > couple
    > > > > of
    > > > > > seconds later, when the loops finished, write ended? When I test

    on
    > XP
    > > > Pro
    > > > > > and Windows Server 2003 the flush doesnt happen - the page takes a
    > > > couple
    > > > > of
    > > > > > seconds to load up and then writes started ended at the same time.
    > > > > >
    > > > > > Also found this article on aspfaq
    > > > > > http://www.aspfaq.com/show.asp?id=2498
    > > > > > but the response.flush() doesn't happen with that sample code

    either
    > > > > >
    > > > > > Any ideas?
    > > > > >
    > > > > > Jon
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Jon Spivey, Jan 21, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marina

    Re: Response.Flush() in code-behind

    Marina, Jul 1, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    461
    William F. Robertson, Jr.
    Jul 1, 2003
  2. William F. Robertson, Jr.

    Re: Response.Flush() does not work

    William F. Robertson, Jr., Aug 5, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    520
    William F. Robertson, Jr.
    Aug 5, 2003
  3. Glen Wilkin via DotNetMonster.com

    Response.Redirect after Response.Flush

    Glen Wilkin via DotNetMonster.com, Apr 15, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    7,059
  4. Replies:
    5
    Views:
    601
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Jun 12, 2007
  5. Richard N.

    Response.Flush / Response.Redirect

    Richard N., Oct 18, 2003, in forum: ASP General
    Replies:
    1
    Views:
    213
    Tom B
    Oct 19, 2003
Loading...

Share This Page