Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

HttpContent.TryComputeLength Method

.NET Framework 4.6 and 4.5

Determines whether the HTTP content has a valid length in bytes.

Namespace:  System.Net.Http
Assembly:  System.Net.Http (in System.Net.Http.dll)

protected internal abstract bool TryComputeLength(
	out long length


Type: System.Int64

The length in bytes of the HTTP content.

Return Value

Type: System.Boolean
Returns Boolean.
true if length is a valid length; otherwise, false.

The TryComputeLength method gives a HTTP content the ability to calculate the content length. This is useful for content types which are able to easily calculate the content length. If computing the content length is not possible or expensive (would require the system to buffer the whole content where the serialization would be expensive or require the system to allocate a lot of memory), this method can return false. If this method returns false, this implies that either chunked transfer is needed or the content must get buffered before being sent to the server.

.NET Framework

Supported in: 4.6, 4.5

.NET for Windows Phone apps

Supported in: Windows Phone 8.1
© 2015 Microsoft