Is there any way to check schema annotation from a base class? Is simple to explain throw an example:
I have this 2 controllers
[Authorize]
public class HomeController : _baseController
{
//Some actions here
}
[AllowAnonymous]
public class OtherController : _baseController
{
//Some actions here
}
Then I have this base class which overrides OnActionExecuting
. The objective is to perform some action if the controller has an annotation.
public class _baseController
{
public override void OnActionExecuting(ActionExecutingContext context)
{
base.OnActionExecuting(context);
if(context.Controller.hasAnnotation("Authorize")){
//do something
}
else if(context.Controller.hasAnnotation("AllowAnonymous")){
//do something
}
}
}
Obviously context.Controller.hasAnnotation
is not a valid method. But you get the idea.