Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Roles Property
Collapse the table of content
Expand the table of content

AuthorizeAttribute.Roles Property

 

Gets or sets the user roles that are authorized to access the controller or action method.

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

public string Roles { get; set; }

Property Value

Type: System.String

The user roles that are authorized to access the controller or action method.

User roles are used to check authorization in an ASP.NET MVC application. A role defines privileges that are available to users who are assigned to that role. Users can belong to more than one role.

The following example shows how to specify that a controller is only available to users in the Administrators roles.

[Authorize(Roles="Administrators")]
public class AdminController : Controller
{
    . . .
}
Return to top
Show:
© 2015 Microsoft