Share via


HttpWebRequest.ContentLength Property

Gets or sets the ContentLength of the request entity body.

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

Syntax

public override long ContentLength { get; set; }

Property Value

The number of bytes of data to send to the Internet resource. The default is -1, which indicates the property has not been set and that there is no request data to send.

Remarks

Getting this property returns the last value set, or -1 if no value has been set.

Setting this property sets the content length, and the application must write that much data to the stream.

This property interacts with SendChunked.

Exceptions

Exception type Condition
InvalidOperationException The content length value cannot be changed, because the request was already submitted.
ArgumentOutOfRangeException The value is negative.

Version Information

Available in the .NET Micro Framework versions 4.0 and 4.1.

See Also

Reference

HttpWebRequest Class
HttpWebRequest Members
System.Net Namespace