ApplicationName Property
Collapse the table of content
Expand the table of content

AuthorizationStoreRoleProvider.ApplicationName Property

 

Gets or sets the name of the authorization store application for which to store and retrieve role information.

Namespace:   System.Web.Security
Assembly:  System.Web (in System.Web.dll)

public override string ApplicationName { get; set; }

Property Value

Type: System.String

The name of the authorization store application for which to store and retrieve role information. The default is the HttpRequest.ApplicationPath property value for the current HttpContext.Request.

Exception Condition
ProviderException

An attempt was made to set the ApplicationName to a string that is longer than 256 characters.

The ApplicationName is used by the AuthorizationStoreRoleProvider to associate users and roles with different authorization-manager applications, which enables multiple ASP.NET applications to use the same authorization-manager policy store to store role information without running into conflicts between duplicate role names. Alternatively, multiple ASP.NET applications can use the same policy store by specifying the same value in the ApplicationName property. The ApplicationName property can be set programmatically, or it can be set declaratively in the application's Web.config file by using the applicationName attribute.

If a value is not specified for the applicationName attribute in the Web.config file, then the HttpRequest.ApplicationPath property value for the current HttpContext.Request object is used.

System_CAPS_noteNote

Authorization-manager application names cannot contain the "/" character that is included in the HttpRequest.ApplicationPath property. As a result, the default value for the ApplicationName property cannot be used as an authorization-manager application name, and in the application's Web.config file, you must always specify an applicationName attribute in the provider element to configure your AuthorizationStoreRoleProvider instance.

System_CAPS_cautionCaution

Because a single default role provider instance is used for all of the requests served by an HttpApplication object, you can have multiple requests executing concurrently and attempting to set the ApplicationName property value. The ApplicationName property is not thread safe for multiple writes, and changing the ApplicationName property value can result in unexpected behavior when there are multiple users of an application. We recommend that you avoid writing code that allows users to set the ApplicationName property unless you must. An example of an application where setting the ApplicationName property may be required is an administrative application that manages role data for multiple applications. Such an application should be a single-user application and not a Web application.

The following example shows the element in the system.web section of the Web.config file for an ASP.NET application. It specifies the application's AuthorizationStoreRoleProvider instance and sets the ApplicationName property to MyApplication.

<roleManager defaultProvider="AuthorizationStoreProvider" 
  enabled="true"
  cacheRolesInCookie="true"
  cookieName=".ASPROLES"
  cookieTimeout="30"
  cookiePath="/"
  cookieRequireSSL="false"
  cookieSlidingExpiration="true"
  cookieProtection="All" >
  <providers>
    <add
      name="SqlProvider"
      type="System.Web.Security.AuthorizationStoreRoleProvider"
      connectionStringName="AuthorizationStoreServices" 
      scopeName="MyScope"
      applicationName="MyApplication" />
  </providers>
</roleManager>

.NET Framework
Available since 2.0
Return to top
Show:
© 2016 Microsoft