Met Websecurity Requireroles
# WebSecurity - RequireRoles()
* * WebSecurity Object](#)
* * *
## Definition
If the current user is not a member of all specified roles, the **RequireRoles()** method sets the HTTP status to 401 (Unauthorized).
* * *
## C# and VB Syntax
WebSecurity.RequireRoles(roles)
* * *
## Example
## Example C#
WebSecurity.RequireRoles("Admin", "Poweruser");
## Example VB
WebSecurity.RequireRoles("Admin", "Poweruser")
* * *
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| _roles_ | String | A comma-separated list of roles that the current user must belong to. |
* * *
## Return Value
None.
* * *
## Errors and Exceptions
Under the following circumstances, any access to the **WebSecurity** object will throw an **InvalidOperationException**:
* The **InitializeDatabaseConnection()** method has not been called
* **SimpleMembership** is not initialized (or is disabled in the site configuration)
* * *
## Remarks
**RequireRoles()** verifies that the current user is a member of **all** specified roles. If the current user is not a member of **all** specified roles, the HTTP status is set to 401 (Unauthorized).
To verify that the current user is authenticated, use the **RequireAuthenticatedUser()** method.
To verify that the current user is a specified user, use the **RequireUser()** method.
* * *
## Technical Data
| Name | Value |
| --- | --- |
| Namespace | WebMatrix.WebData |
| Assembly | WebMatrix.WebData.dll |
* * WebSecurity Object](#)
YouTip