편집

다음을 통해 공유


RoleManagerSection.CacheRolesInCookie Property

Definition

Gets or sets a value indicating whether the current user's roles are cached in a cookie.

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

Property Value

true if the current user's roles are cached in a cookie; otherwise, false. The default is false.

Attributes

Examples

The following code example demonstrates how to use the CacheRolesInCookie property. This code example is part of a larger example provided for the RoleManagerSection class.

// Display CacheRolesInCookie property.
Console.WriteLine("CacheRolesInCookie: {0}",
  configSection.CacheRolesInCookie);
' Display CacheRolesInCookie property.
Console.WriteLine("CacheRolesInCookie: {0}", _
 configSection.CacheRolesInCookie)

Remarks

The CacheRolesInCookie property returns a Boolean value indicating whether cookie storage for role names is enabled.

When the CacheRolesInCookie property is set to true in the configuration file, role information for each user is stored in a cookie on the client. When role management checks to determine whether a user is in a particular role, the roles cookie is checked before calling the role provider to check the list of roles at the data source. The cookie is dynamically updated on the client to cache the most recently validated role names.

You can improve the reliability of the role names that are cached in a cookie by specifying a CookieProtection property when you configure the roleManager section of the configuration file. The default CookieProtection property is All, which encrypts role names in the cookie and validates that the cookie contents have not been altered.

Applies to