According to MSDN:
ContentLength - Indicates the length in bytes of the content sent by the client.
TotalBytes - the number of bytes in the current input stream.
InputStream.Length - the length of bytes in the input stream.
So the last two are the same. Here's what Reflector says about the ContentLength property:
public int ContentLength { get { if ((this._contentLength == -1) && (this._wr != null)) { string knownRequestHeader = this._wr.GetKnownRequestHeader(11); if (knownRequestHeader != null) { try { this._contentLength = int.Parse(knownRequestHeader, CultureInfo.InvariantCulture); } catch { } } else if (this._wr.IsEntireEntityBodyIsPreloaded()) { byte[] preloadedEntityBody = this._wr.GetPreloadedEntityBody(); if (preloadedEntityBody != null) { this._contentLength = preloadedEntityBody.Length; } } } if (this._contentLength < 0) { return 0; } return this._contentLength; } }
source share