GetAllRoles Method

Roles.GetAllRoles Method ()


Gets a list of all the roles for the application.

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

public static string[] GetAllRoles()

Return Value

Type: System.String[]

A string array containing the names of all the roles stored in the data source for the application.

Exception Condition

Role management is not enabled.

The GetAllRoles method calls the RoleProvider.GetAllRoles method of the default role provider to get a list of all the roles from the data source for an application. Only the roles for the application that is specified in the ApplicationName property are retrieved.

The following code example uses the GetAllRoles method to get the list of roles for an application and bind the results to a System.Web.UI.WebControls.GridView control. For an example of a Web.config file that enables role management, see Roles.

System_CAPS_security Security Note

This example contains a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.

.NET Framework
Available since 2.0
Return to top
© 2015 Microsoft