HttpCookiesSection.HttpOnlyCookies 属性

定义

获取或设置一个指示是否启用了浏览器的 HttpOnly Cookie 支持的值。Gets or sets a value indicating whether the support for the browser's HttpOnly cookie is enabled.

此 API 支持产品基础结构,不能在代码中直接使用。

public:
 property bool HttpOnlyCookies { bool get(); void set(bool value); };
[System.Configuration.ConfigurationProperty("httpOnlyCookies", DefaultValue=Mono.Cecil.CustomAttributeArgument)]
public bool HttpOnlyCookies { get; set; }
[<System.Configuration.ConfigurationProperty("httpOnlyCookies", DefaultValue=Mono.Cecil.CustomAttributeArgument)>]
member this.HttpOnlyCookies : bool with get, set
Public Property HttpOnlyCookies As Boolean

属性值

Boolean

如果启用了 true 支持,则为 HttpOnly,否则为 falsetrue if support for the HttpOnly cookie is enabled; otherwise, false. 默认值为 falseThe default is false.

属性

示例

下面的代码示例说明如何使用 HttpOnlyCookies 属性。The following code example shows how to use the HttpOnlyCookies property.


// Get the current HttpOnlyCookies.
Boolean httpOnlyCookiesValue = 
    httpCookiesSection.HttpOnlyCookies;

// Set the HttpOnlyCookies.
httpCookiesSection.HttpOnlyCookies = 
    false;


' Get the current HttpOnlyCookies.
Dim httpOnlyCookiesValue As Boolean = _
httpCookiesSection.HttpOnlyCookies

' Set the HttpOnlyCookies.
httpCookiesSection.HttpOnlyCookies = _
False

注解

httpCookies元素支持使用 HttpOnly cookie。The httpCookies element supports the use of HttpOnly cookies. HttpOnly``HttpOnly在 Internet Explorer 6 中引入了属性) 的 cookie (cookie,以帮助降低跨站点脚本的风险。HttpOnly cookies (cookies with the HttpOnly attribute) were introduced in Internet Explorer 6 to help mitigate the risk of cross-site scripting. HttpOnly属性阻止通过客户端脚本访问 cookie。The HttpOnly attribute prevents cookies from being accessed through client-side script. Cookie 中包含的任何信息 HttpOnly 都不太可能泄露给黑客或恶意网站。Any information contained in an HttpOnly cookie is less likely to be disclosed to a hacker or a malicious Web site. 有关详细信息,请搜索 MSDN ("HttpOnly" 的 msdn.microsoft.com) 。For more information, search MSDN (msdn.microsoft.com) for "HttpOnly."

适用于

另请参阅