Roles.CookieProtectionValue 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个值,该值指示如何保护 Cookie 中缓存的角色名称。
public:
static property System::Web::Security::CookieProtection CookieProtectionValue { System::Web::Security::CookieProtection get(); };
public static System.Web.Security.CookieProtection CookieProtectionValue { get; }
static member CookieProtectionValue : System.Web.Security.CookieProtection
Public Shared ReadOnly Property CookieProtectionValue As CookieProtection
属性值
枚举值之 CookieProtection 一,指示如何在 Cookie 中缓存的角色名称受到保护。 默认值为 All。
示例
以下示例显示了 ASP.NET 应用程序的 Web.config 文件中 的 roleManager 元素 system.web 。 它指定应用程序使用 SqlRoleProvider 实例并将属性设置为 cookieProtectionEncrypted.
<roleManager defaultProvider="SqlProvider"
enabled="true"
cacheRolesInCookie="true"
cookieName=".ASPROLES"
cookieTimeout="30"
cookiePath="/MyApplication"
cookieRequireSSL="false"
cookieSlidingExpiration="true"
cookieProtection="Encrypted" >
<providers>
<add
name="SqlProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="SqlServices"
applicationName="MyApplication" />
</providers>
</roleManager>
注解
通过在 ASP.NET 应用程序的 Web.config 文件中设置 cookieProtection 属性,可以指定为应用程序缓存角色的 Cookie 的保护。 该 cookieProtection 属性采用一个 CookieProtection 枚举值,该值指示角色名称是加密、验证还是两者均未加密。