Monday, 11 January 2016

ASP.NET MVC - Configure Multiple Roles for Controller

Using ASP.NET Identity you can easily set access to Controllers based on Roles.
You can use the "Authorize" for this.

Setting access to single Role:
[Authorize(Roles="Admin")]

Setting access to single Role:
[Authorize(Roles="Admin, User")]

Eg:
[Authorize(Roles = "SuperAdmin", "Admin")]
public ActionResult Register()
{
    return View();
}

Its that simple. Happy coding... :)

No comments:

Post a comment