문제

In ASP.NET you can decorate a method as such

[Authorize(Roles="Moderator,Tester")]
Function ActionResult Foo()
{
   return View();
}

This will limit access to users that are in one of the roles specified.

I have a requirement where the user must be in all the roles specified. I can create a new role for this; But I was wondering if it is possible to decorate the method such, that the user must be part of all the roles specified?

Is this possible using the Authorise attribute or will I need to create my own?

도움이 되었습니까?

해결책

Simply use The [Authorize] attribute multiple times:

[Authorize(Roles="Moderator")]
[Authorize(Roles="Tester")]
Function ActionResult Foo()
{
   return View();
}

This will require the user to be in both (or more) roles.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top