Mono Class Library: System.Net.HttpWebRequest Overview | MembersSystem.Net.HttpWebRequest.ContentLength Property |
Gets or sets the Content-length HTTP header. [Edit]
|
A long value that specifies the number of bytes of data to send to the Internet resource. The default is -1, which indicates that this value has not been set. [Edit]
Type Reason InvalidOperationException Data has already been written to the request stream. [Edit] ArgumentOutOfRangeException A value less than zero is specified for a set operation. [Edit]
The HttpWebRequest.ContentLength property contains the value to send as the Content-length HTTP header of the request.
Any value other than -1 in the HttpWebRequest.ContentLength property indicates that the request will upload data; only methods that upload data are allowed in the HttpWebRequest.Method property.
This property is required to be set prior to writing data to the request data stream. Once the HttpWebRequest.ContentLength property is set to a value, that number of bytes is required to be written to the request data stream.
Note: Get the request data stream by calling HttpWebRequest.GetRequestStream , or HttpWebRequest.BeginGetRequestStream(AsyncCallback, object) and HttpWebRequest.EndGetRequestStream(IAsyncResult) .Note:[Edit]For additional information see section 14.13 of IETF RFC 2616 - HTTP/1.1.
This property overrides WebRequest.ContentLength.
Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0