Reputation: 307
I get the idea that the controller is checking (somewhere) for the actual user roles, but what do those square brackets mean?
It looks like some kind of directive, but i could not find neither who parses this directive nor where the Authorize function is defined.
Upvotes: 2
Views: 1011
Reputation: 239430
The Authorize
attribute is actually AuthorizeAttribute
. That may help your searches. The brackets are a directive that means that the stuff inside is an attribute. Attributes are processed differently based on what they're wrapping. In the case of AuthorizeAttribute
it's hooking into the request and running it's own code before the action's code runs.
Upvotes: 1
Reputation: 141678
That is the syntax for an attribute in C#:
Attributes can be placed on most any declaration, though a specific attribute might restrict the types of declarations on which it is valid. In C#, you specify an attribute by placing the name of the attribute, enclosed in square brackets ([]), above the declaration of the entity to which it applies.
So what you have is an AuthorizeAttribute
on your controller. This is a kind of action filter. The ASP.NET / MVC runtime is who "checks" and enforces action filters.
Upvotes: 4