语言

HttpContentHeaders.ContentLength 属性

定义

获取或设置 HTTP 响应中内容标头的值 Content-Length 。

public:
 property Nullable<long> ContentLength { Nullable<long> get(); void set(Nullable<long> value); };
public long? ContentLength { get; set; }
member this.ContentLength : Nullable<int64> with get, set
Public Property ContentLength As Nullable(Of Long)

属性值

HTTP 响应中内容标头的值 Content-Length 。

例外

从未设置该值,并且 HttpContent 基础在尝试计算它时被释放。

注解

如果未设置标头,则可以通过缓冲内容或使用 TryComputeLength 按需计算其值。

适用于