Gets or sets the name of the application for which to store and retrieve role information.
Assembly: System.Web (in System.Web.dll)
The is used by the SqlRoleProvider to associate users and roles with different applications. This enables multiple applications to use the same database to store user and role information without running into conflicts between duplicate user names or role names. Multiple ASP.NET applications can use the same database by specifying the same value in the property. The property can be set programmatically, or it can be set declaratively in the configuration file for the Web application using the applicationName attribute.
If a value is not specified for the applicationName attribute in the configuration file for the Web application, then the HttpRequest.ApplicationPath property value for the current HttpContext.Request object is used.
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 property value. The property is not thread safe for multiple writes, and changing the property value can result in unexpected behavior for multiple users of an application. It is recommended that you avoid writing code that allows users to set the property unless you must. An example of an application where setting the 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 roleManager element in the system.web section of the Web.config file for an ASP.NET application. It specifies the application's SqlRoleProvider instance and sets the property to MyApplication.
<roleManager defaultProvider="SqlProvider" enabled="true" cacheRolesInCookie="true" cookieName=".ASPROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All" > <providers> <add name="SqlProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="SqlServices" applicationName="MyApplication" /> </providers> </roleManager>
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.