HttpCacheVaryByHeaders.UserLanguage 属性

定义

获取或设置一个值,该值指示 ASP.NET 输出缓存是否随 Accept-Language 标头改变缓存的响应,并将该标头追加到传出的 Vary HTTP 标头。Gets or sets a value indicating whether the ASP.NET output cache varies the cached responses by the Accept-Language header, and appends it to the out-going Vary HTTP header.

public:
 property bool UserLanguage { bool get(); void set(bool value); };
public bool UserLanguage { get; set; }
member this.UserLanguage : bool with get, set
Public Property UserLanguage As Boolean

属性值

Boolean

当 ASP.NET 输出缓存随 true 标头而变化并将该标头添加到被发送到客户端的 Accept-Language HTTP 标头时,则为 Vary;否则为 falsetrue when ASP.NET output cache varies by the Accept-Language header and adds it to the Vary HTTP header sent to the client; otherwise, false. 默认值是 falseThe default value is false.

示例

下面的代码示例演示了仅当属性为时,才执行某些操作 UserLanguage trueThe following code example demonstrates how some action is performed only if the UserLanguage property is true.

Response.Cache.VaryByHeaders.UserLanguage = true;

Response.Cache.VaryByHeaders.UserLanguage = True

注解

Vary标头指示请求标头字段,该字段用于确定为响应客户端请求而发送了多个缓存的响应。The Vary header indicates the request-header fields that the server uses to determine which of multiple cached responses is sent in response to a client request. Accept-Language字段指定服务器根据客户端可接受的语言选择响应。The Accept-Language field specifies that the server selects the response based on languages acceptable to the client.

有关详细信息,请参阅 万维网联合会 (W3C) 网站上的 RFC 2616:超文本传输协议-HTTP/1.1。For more information, see RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1, available on the World Wide Web Consortium (W3C) Web site. 有关完整的详细信息,请参阅第14节 "标头字段定义"。See section 14, "Header Field Definitions", for complete details.

适用于