Shyju
Shyju

Reputation: 218782

Response.Flush not working ASP.NET

I have an aspx page where i am Processing a large number of records from a table and doing some manipulation.after each manipuation,(each record),I have a Response.Write("Record : "+rec); Response.Flush()

I have set Response.Buffer property to false. It is working fine But If i want to render the output as a table row,its not working as of Response.Write After fininshing all the records in the loop only , the table is getting printed

How to solve this ?

Upvotes: 4

Views: 12939

Answers (6)

Glen Little
Glen Little

Reputation: 7128

For anyone else having this problem...

Be aware that if your IIS server is compressing the output with GZIP, then it will seem to ignore all Response.Flush calls. This is turned on by default in IIS7 and on Windows 7.

And, if you are testing with Fiddler, be sure to turn on "Streaming" mode, or Fiddler will collect the flushed HTML and hold it until the connection is completed. The relevant Fiddler settings found under the Performance tab:

enter image description here

Upvotes: 19

Harshith C
Harshith C

Reputation: 113

It seems the issue is very old. Anyway there are few ways to solve this issue. . There are lots of reasons why Response.flush() generates an exception.

  1. If its from IIS then there is a flag

Response.TrySkipIisCustomErrors = true;

  1. If you are using update panel in your project then you have to bind the event with PostBackTrigger Class enter image description here

Upvotes: 0

n8wrl
n8wrl

Reputation: 19765

Definately the table. To prove this to yourself, change your table-markup-oriented response.Write()s to just plain text. you'll see it accumulate. If the table has to be this big and you want to render it from the server, you should fix the column sizes and break the table up into one-per-row or some other subset so content appears gradually as you want.

Upvotes: 0

Timothy Lee Russell
Timothy Lee Russell

Reputation: 3748

I would guess that the table doesn't exist from the browser's perspective until you write out the end table tag.

You could write out a bunch of divs with a stylesheet controlling their width.

.column1 { width: 40px; }
.column2 { width: 40px; }

Response.Write("<div id=\"column1\">some text</div><div id=\"column2\">some text</div>");
Response.Flush();

Or you could write out an entire table for each row...?

Response.Write("<table><tr><td>some text</td></tr></table>");
Response.Flush();

Upvotes: 0

Eduardo Molteni
Eduardo Molteni

Reputation: 39423

I will add to Darryl answer that you can close the table as soon as posible and then fill the rest of the table using JQuery or similar.

Upvotes: 1

Darryl Braaten
Darryl Braaten

Reputation: 5231

Most browsers will not render tables until the table is complete. You can try making the table fixed format, css table-layout: fixed, along with specifying column sizes.

Upvotes: 7

Related Questions