FormsAuthenticationConfiguration.Protection 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置用于加密 Cookie 的加密类型。
public:
property System::Web::Configuration::FormsProtectionEnum Protection { System::Web::Configuration::FormsProtectionEnum get(); void set(System::Web::Configuration::FormsProtectionEnum value); };
[System.Configuration.ConfigurationProperty("protection", DefaultValue=System.Web.Configuration.FormsProtectionEnum.All)]
public System.Web.Configuration.FormsProtectionEnum Protection { get; set; }
[<System.Configuration.ConfigurationProperty("protection", DefaultValue=System.Web.Configuration.FormsProtectionEnum.All)>]
member this.Protection : System.Web.Configuration.FormsProtectionEnum with get, set
Public Property Protection As FormsProtectionEnum
属性值
枚举值之 FormsProtectionEnum 一。 默认值为 All。
注意 如果希望数据验证和加密都有助于保护 Cookie,请务必使用此属性的默认值。 此选项使用基于
为了改进 Cookie 的保护,你可能还需要将 Cookie true设置为 RequireSSL 。
- 属性
示例
下面的代码示例演示如何访问 Protection 属性。 请参阅类主题中的 FormsAuthenticationConfiguration 代码示例,了解如何获取该部分。
// Get the current Protection.
FormsProtectionEnum currentProtection =
formsAuthentication.Protection;
// Set the Protection property.
formsAuthentication.Protection =
FormsProtectionEnum.All;
' Get the current Protection.
Dim currentProtection As FormsProtectionEnum =
formsAuthentication.Protection
' Set the Protection property.
formsAuthentication.Protection = FormsProtectionEnum.All