How does IIS or Framework set the Content-Length header ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I'm experiencing a strange problem with an aspx page. This page does NOT set
the Content-Length header. When hosted on my development PC (with IIS 5.0 and
..Net 1.1), the HTTP response however contains a Content-Length header. When
hosted on our test server (IIS 5.0 and .Net 1.1 as well) the Content-Length
is not set, causing the server to send the response (roughy 10KB) in several
chunks which seems to dramatically decrease performances.

My questions are:
- How does IIS (which layer or component and with which algorithm) sets the
Content-Length for a dynamic page ?
- Which conditions would make our test server not to fill this header
hencing causing (I guess so) this chunked encoding response ?

Any thoughs or idea ?
Thanks in advance
Arno
 
Hello Arno,

As far as I remember, this has something to do with the Response.Buffer
property. When the response is buffered, the framework knows the length of
the response beforehand and sets the Content-Length header appropriately. On
the other hand, when the response is not buffered, there is no way to
reliably determine its length, so the framework is under no obligation to
provide the correct Content-Length header.
 
Many thanks Dmitriy for this explanation.

You got it !
If I set the <pages buffer="false" [...]/> in the machine.config (or in the
app config file), the response is being sent in an incredible number of
chunks 'cause the framework tries to send the response ASAP, and the
content-length is not set.

Cheers,
Arno

Dmitriy Lapshin said:
Hello Arno,

As far as I remember, this has something to do with the Response.Buffer
property. When the response is buffered, the framework knows the length of
the response beforehand and sets the Content-Length header appropriately. On
the other hand, when the response is not buffered, there is no way to
reliably determine its length, so the framework is under no obligation to
provide the correct Content-Length header.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

Arno said:
Hello,

I'm experiencing a strange problem with an aspx page. This page does NOT
set
the Content-Length header. When hosted on my development PC (with IIS 5.0
and
.Net 1.1), the HTTP response however contains a Content-Length header.
When
hosted on our test server (IIS 5.0 and .Net 1.1 as well) the
Content-Length
is not set, causing the server to send the response (roughy 10KB) in
several
chunks which seems to dramatically decrease performances.

My questions are:
- How does IIS (which layer or component and with which algorithm) sets
the
Content-Length for a dynamic page ?
- Which conditions would make our test server not to fill this header
hencing causing (I guess so) this chunked encoding response ?

Any thoughs or idea ?
Thanks in advance
Arno
 
Back
Top