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.
Type Reason InvalidOperationException Data has already been written to the request stream. ArgumentOutOfRangeException A value less than zero is specified for a set operation.
The HttpWebRequest.ContentLength property contains the value to send as the Content-length HTTP header with the request.
Any value other than -1 in the HttpWebRequest.ContentLength property indicates that the request uploads data and that only methods that upload data are allowed to be set in the HttpWebRequest.Method property.
After the HttpWebRequest.ContentLength property is set to a value, that number of bytes must be written to the request stream that is returned by calling the HttpWebRequest.GetRequestStream method or both the HttpWebRequest.BeginGetRequestStream(AsyncCallback, object) and the HttpWebRequest.EndGetRequestStream(IAsyncResult) methods.
The value for this property is stored in System.Net.WebHeaderCollection. If WebHeaderCollection is set, the property value is lost.