Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
AuthorizationPolicyBuilder.RequireRole Method
Definition
- Namespace:
- Microsoft.AspNetCore.Authorization
- Assembly:
- Microsoft.AspNetCore.Authorization.dll
- Package:
- Microsoft.AspNetCore.Authorization v1.0.0
- Package:
- Microsoft.AspNetCore.Authorization v1.1.0
- Package:
- Microsoft.AspNetCore.Authorization v10.0.0
- Package:
- Microsoft.AspNetCore.Authorization v11.0.0-preview.4.26230.115
- Package:
- Microsoft.AspNetCore.Authorization v2.0.0
- Package:
- Microsoft.AspNetCore.Authorization v2.1.0
- Package:
- Microsoft.AspNetCore.Authorization v2.2.0
- Package:
- Microsoft.AspNetCore.Authorization v3.0.3
- Package:
- Microsoft.AspNetCore.Authorization v3.1.18
- Package:
- Microsoft.AspNetCore.Authorization v5.0.9
- Package:
- Microsoft.AspNetCore.Authorization v6.0.6
- Package:
- Microsoft.AspNetCore.Authorization v7.0.5
- Package:
- Microsoft.AspNetCore.Authorization v8.0.19
- Package:
- Microsoft.AspNetCore.Authorization v9.0.8
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| RequireRole(String[]) |
Adds a RolesAuthorizationRequirement to the current instance which enforces that the current user must have at least one of the specified roles. |
| RequireRole(IEnumerable<String>) |
Adds a RolesAuthorizationRequirement to the current instance which enforces that the current user must have at least one of the specified roles. |
RequireRole(String[])
Adds a RolesAuthorizationRequirement to the current instance which enforces that the current user must have at least one of the specified roles.
public:
Microsoft::AspNetCore::Authorization::AuthorizationPolicyBuilder ^ RequireRole(... cli::array <System::String ^> ^ roles);
public Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder RequireRole(params string[] roles);
member this.RequireRole : string[] -> Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder
Public Function RequireRole (ParamArray roles As String()) As AuthorizationPolicyBuilder
Parameters
- roles
- String[]
The allowed roles.
Returns
A reference to this instance after the operation has completed.
Applies to
RequireRole(IEnumerable<String>)
Adds a RolesAuthorizationRequirement to the current instance which enforces that the current user must have at least one of the specified roles.
public:
Microsoft::AspNetCore::Authorization::AuthorizationPolicyBuilder ^ RequireRole(System::Collections::Generic::IEnumerable<System::String ^> ^ roles);
public Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder RequireRole(System.Collections.Generic.IEnumerable<string> roles);
member this.RequireRole : seq<string> -> Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder
Public Function RequireRole (roles As IEnumerable(Of String)) As AuthorizationPolicyBuilder
Parameters
- roles
- IEnumerable<String>
The allowed roles.
Returns
A reference to this instance after the operation has completed.
Applies to
Feedback
Was this page helpful?
