HttpCookiesSection 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
为 Web 应用程序使用的 Cookie 配置属性。
此 API 支持产品基础结构,不能在代码中直接使用。
public ref class HttpCookiesSection sealed : System::Configuration::ConfigurationSection
public sealed class HttpCookiesSection : System.Configuration.ConfigurationSection
type HttpCookiesSection = class
inherit ConfigurationSection
Public NotInheritable Class HttpCookiesSection
Inherits ConfigurationSection
- 继承
示例
下面的代码示例演示如何从现有 Web 应用程序的配置文件中获取 HttpCookiesSection 对象。
// Get the Web application configuration.
System.Configuration.Configuration webConfig =
WebConfigurationManager.OpenWebConfiguration("/aspnetTest");
// Get the section.
string configPath = "system.web/httpCookies";
System.Web.Configuration.HttpCookiesSection httpCookiesSection =
(System.Web.Configuration.HttpCookiesSection)webConfig.GetSection(
configPath);
' Get the Web application configuration.
Dim webConfig _
As System.Configuration.Configuration = _
WebConfigurationManager.OpenWebConfiguration("/aspnetTest")
' Get the section.
Dim configPath As String _
= "system.web/httpCookies"
Dim httpCookiesSection _
As System.Web.Configuration.HttpCookiesSection = _
CType(webConfig.GetSection(configPath), _
System.Web.Configuration.HttpCookiesSection)
注解
该 HttpCookiesSection 类提供了一种以编程方式访问和修改 httpCookies 配置文件部分的方法。
它定义默认应用于应用程序发出的所有 Cookie 的设置,除非发出 Cookie 的代码会重写这些设置。
元素 httpCookies 的一个目标是支持使用 HttpOnly Cookie。
HttpOnly Internet Explorer 6 中引入了 Cookie(带 HttpOnly 特性的 Cookie),以帮助降低跨站点脚本的风险。 该 HttpOnly 属性可防止通过客户端脚本访问 Cookie。 Cookie 中包含的 HttpOnly 任何信息不太可能被泄露给黑客或恶意网站。 有关详细信息,请在 MSDN(msdn.microsoft.com)中搜索“HttpOnly”。
注释
构造函数
| 名称 | 说明 |
|---|---|
| HttpCookiesSection() |
此 API 支持产品基础结构,不能在代码中直接使用。 初始化 HttpCookiesSection 类的新实例。 |
属性
| 名称 | 说明 |
|---|---|
| CurrentConfiguration |
此 API 支持产品基础结构,不能在代码中直接使用。 获取对顶级 Configuration 实例的引用,该实例表示当前 ConfigurationElement 实例所属的配置层次结构。 (继承自 ConfigurationElement) |
| Domain |
此 API 支持产品基础结构,不能在代码中直接使用。 获取或设置 Cookie 域名。 |
| ElementInformation |
此 API 支持产品基础结构,不能在代码中直接使用。 获取一个 ElementInformation 对象,该对象包含 ConfigurationElement 对象的不可自定义信息和功能。 (继承自 ConfigurationElement) |
| ElementProperty |
此 API 支持产品基础结构,不能在代码中直接使用。 获取表示 ConfigurationElementProperty 对象本身的 ConfigurationElement 对象。 (继承自 ConfigurationElement) |
| EvaluationContext |
此 API 支持产品基础结构,不能在代码中直接使用。 获取 ContextInformation 对象的 ConfigurationElement 对象。 (继承自 ConfigurationElement) |
| HasContext |
此 API 支持产品基础结构,不能在代码中直接使用。 获取一个值,该值指示 CurrentConfiguration 属性是否 |
| HttpOnlyCookies |
此 API 支持产品基础结构,不能在代码中直接使用。 获取或设置一个值,该值指示是否启用对浏览器的 |
| Item[ConfigurationProperty] |
此 API 支持产品基础结构,不能在代码中直接使用。 获取或设置此配置元素的属性或属性。 (继承自 ConfigurationElement) |
| Item[String] |
此 API 支持产品基础结构,不能在代码中直接使用。 获取或设置此配置元素的属性、属性或子元素。 (继承自 ConfigurationElement) |
| LockAllAttributesExcept |
此 API 支持产品基础结构,不能在代码中直接使用。 获取锁定属性的集合。 (继承自 ConfigurationElement) |
| LockAllElementsExcept |
此 API 支持产品基础结构,不能在代码中直接使用。 获取锁定元素的集合。 (继承自 ConfigurationElement) |
| LockAttributes |
此 API 支持产品基础结构,不能在代码中直接使用。 获取锁定属性的集合。 (继承自 ConfigurationElement) |
| LockElements |
此 API 支持产品基础结构,不能在代码中直接使用。 获取锁定元素的集合。 (继承自 ConfigurationElement) |
| LockItem |
此 API 支持产品基础结构,不能在代码中直接使用。 获取或设置一个值,该值指示元素是否已锁定。 (继承自 ConfigurationElement) |
| Properties |
此 API 支持产品基础结构,不能在代码中直接使用。 获取属性的集合。 (继承自 ConfigurationElement) |
| RequireSSL |
此 API 支持产品基础结构,不能在代码中直接使用。 获取或设置一个值,该值指示是否需要安全套接字层 (SSL) 通信。 |
| SameSite |
此 API 支持产品基础结构,不能在代码中直接使用。 获取或设置 Cookie 的 SameSite 属性的值。 |
| SectionInformation |
此 API 支持产品基础结构,不能在代码中直接使用。 获取一个 SectionInformation 对象,该对象包含不可自定义的信息和功能 ConfigurationSection 。 (继承自 ConfigurationSection) |