Roles.CookieProtectionValue 属性

定义

获取一个指示如何保护在 Cookie 中缓存的角色名称的值。Gets a value that indicates how role names cached in a cookie are protected.

public:
 static property System::Web::Security::CookieProtection CookieProtectionValue { System::Web::Security::CookieProtection get(); };
public static System.Web.Security.CookieProtection CookieProtectionValue { get; }
member this.CookieProtectionValue : System.Web.Security.CookieProtection
Public Shared ReadOnly Property CookieProtectionValue As CookieProtection

属性值

CookieProtection 枚举值的其中一个值指示如何保护在 Cookie 中缓存的角色名称。One of the CookieProtection enumeration values indicating how role names that are cached in a cookie are protected. 默认值为 AllThe default is All.

示例

下面的示例演示了 ASP.NET 应用程序的system.web web.config 文件的节中的 roleManager 元素。The following example shows the roleManager element in the system.web section of the Web.config file for an ASP.NET application. 它指定应用程序使用SqlRoleProvider实例,并将属性设置cookieProtectionEncryptedIt specifies that the application uses a SqlRoleProvider instance and sets cookieProtection attribute to Encrypted.

<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 保护。You can specify the protection of the cookie where roles are cached for your application by setting the cookieProtection attribute in the Web.config file for your ASP.NET application. 特性采用一个CookieProtection枚举值,该值指示是否对角色名称进行加密、验证和/或验证。 cookieProtectionThe cookieProtection attribute takes a CookieProtection enumeration value that indicates whether the role names are encrypted, validated, both, or neither.

适用于

另请参阅