umki
umki

Reputation: 779

Asp.Net Mvc Identity Role Management

I am using Identity in my MVC project. Nowadays, i am trying to develop my authentication system and implement group-based identity.

I wonder what the way is, are you following to manage roles. IE. i have an action in one of my controller and named, CreateNewStudent. I am creating new role names, CanCreateStudent and write the related action filter, top of my action.

Is that the only way ? Should i need to put action filters one by one ?

Regards.

Upvotes: 0

Views: 660

Answers (1)

Yogiraj
Yogiraj

Reputation: 1982

You could also have those attributes on controllers. In the code below for example, if the controller inherited from the base, the actions inside of that will require authentication. You can add roles in there.

[Authorize]
public class BaseController : Controller
{
     //do some common operations 
}
public class HomeController : BaseController
{
    public virtual ActionResult Index()
    {
        ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";

        return View();
    }
}

Upvotes: 1

Related Questions