Configure the application rolemanager element for role management

Source: Internet
Author: User
Rolemanager element (ASP. NET architecture)

Configure applications for role management.

This element is a new element in. NET Framework 2.0.

Configuration element (general architecture setting)
System. Web elements (ASP. NET setting Architecture)
Rolemanager element (ASP. NET architecture)

<roleManagercacheRolesInCookie="true|false"cookieName="name"cookiePath="/"cookieProtection="All|Encryption|Validation|None"cookieRequireSSL="true|false "cookieSlidingExpiration="true|false "cookieTimeout="number of minutes"createPersistentCookie="true|false"defaultProvider="provider name"domain="cookie domain">enabled="true|false"maxCachedResults="maximum number of role names cached"<providers>...</providers></roleManager>
Attributes and elements

The following sections describe the attributes, child elements, and parent elements involved in this section.

Attribute

Attribute

Description

Cacherolesincookie

Optional Boolean attribute.

When verifying whether a user is in a specific role, check the cookie first, and then use the role provider to check the role list in the data source. If the value is true, the list of role names in the current user's cookie is cached; otherwise, the value is false.

The default value is false.

Cookiename

Optional string attributes.

The name of the cookie that stores the role name.

The default value is ". aspxroles ".

Cookiepath

Optional string attributes.

The path of the role name Cookie.

The default value is "/".

Cookieprotection

Optional cookieprotection attributes.

Specifies one of the cookieprotection enumerated values.

The default value is all.

Cookierequiressl

Optional Boolean attribute.

Specifies whether the role name Cookie needs to be sent to the server using SSL.

If this parameter is set to true, the role name Cookie needs to be sent to the server using SSL.

The default value is false.

Cookieslidingexpiration

Optional Boolean attribute.

Specify whether or not to regularly reset the expiration date and time of the role name Cookie.

If it is set to true, the cookie expiration date and time are initially set to the addition of the current date and time and cookietimeout value (minutes. When users continue to actively use ASP. NET applications, the cookie expiration date and time will be automatically updated when the remaining time is less than half of the cookietimeout value. For more information, see expires.

The default value is true.

Cookietimeout

Optional int32 attribute.

Role name: the time before the cookie expires (in minutes ).

The default value is "30" (minutes ).

Createpersistentcookie

Optional Boolean attribute.

Specifies whether the role name Cookie is a session cookie. That is, the cookie is lost when the browser is disabled.

If set to true, the role name Cookie is a persistent cookie that can be used across multiple browser sessions. Set the expiration date and time of the persistent cookie to the addition of the current date and time and cookietimeout value (minutes.

The default value is false.

Defaultprovider

Optional string attributes.

The name of the default role provider. For more information, see provider.

The default value is "aspnetsqlroleprovider ".

Domain

Optional string attributes.

Specifies the Domain value of the role name Cookie.

The default value is the default value of httpcookie. The value is an empty string ("").

Enabled

Optional Boolean attribute.

Specifies whether to enable role management.

If this parameter is set to true, role management is enabled.

In the machine. config file, the default value is false.

Maxcachedresults

Optional int32 attribute.

Specifies the maximum number of role names cached in the role cookie.

The default value is 25.

Inherited attributes

Optional attributes.

Attributes inherited by all section elements. For more information, see section general attributes inherited by elements.

Child Element

Element

Description

Providers

Optional.

Defines a set of role providers for role management.

Parent Element

Element

Description

Configuration

Specifies the root element required in each configuration file used by the Common Language Runtime Library and. NET Framework application.

System. Web

Specify the root element for the ASP. NET configuration section.

Remarks

The rolemanager element configures applications for role management.

For information on accessing and modifying the configuration values of the rolemanager element in the application code, see rolemanagersection.

Default Configuration

The following default rolemanager elements are not explicitly configured in the machine. config file or the root web. config file. However, it is the default configuration returned by the application. The provider is explicitly configured in the machine. config file.

Copy code
<roleManagerenabled="false"cacheRolesInCookie="false"cookieName=".ASPXROLES"cookieTimeout="30"cookiePath="/"cookieRequireSSL="false"cookieSlidingExpiration="true"cookieProtection="All"defaultProvider="AspNetSqlRoleProvider"createPersistentCookie="false"maxCachedResults="25"><providers><clear /><addconnectionStringName="LocalSqlServer"applicationName="/"name="AspNetSqlRoleProvider"type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /><addapplicationName="/"name="AspNetWindowsTokenRoleProvider"type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /></providers></roleManager>
Example

The following code example shows how to configure an ASP. NET application to use the sqlroleprovider class to store and retrieve role information.

Copy code
<configuration><system.web><roleManager defaultProvider="SqlProvider"enabled="true"cacheRolesInCookie="true"cookieName=".ASPROLES"cookieTimeout="30"cookiePath="/"cookieRequireSSL="false"cookieSlidingExpiration="true"cookieProtection="All" ><providers><addname="SqlProvider"type="System.Web.Security.SqlRoleProvider"connectionStringName="SqlServices"applicationName="SampleApplication" /></providers></roleManager></system.web></configuration>
Element Information

Configuration section Handler

Rolemanagersection

Configuration Member

Rolemanager

Configurable location

Machine. config

Root-level Web. config

Application-level Web. config

Requirements

Microsoft Internet Information Service (IIS) version 5.0, 5.1, or 6.0

. NET Framework 2.0

Microsoft Visual Studio 2003 or Visual Studio 2005

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.