Using the Authorize attribute, I can specify the roles that are allowed access to resources.
[Authorize(Roles="User")]
But if I have an admin user who is allowed to go to any resource, I also need to specify this
[Authorize(Roles="User, Administrator")]
But maybe there is some way, can I somehow say that the Administrator is allowed to go anywhere and not specify it in the Authorize attribute?
So, I mean that if somewhere in the code ( on the controller or in action ) [Authorize(Roles="User")] is specified, this means that the administrator role will also be available there.
Or maybe I can install it for all authorize roles dynamically, like when I launch the application?
Any ideas?
UPDATED:
I currently have one admin controller with the Authorize [Authorize(Role="Administrator")] attribute, and I have some actions in some other controllers with the [Authorize(Role="User")] attributes, so I will need to add "Administrator" there if I have not found a better solution.
authorization asp.net-mvc-3
Joper
source share