I have a custom attribute which is executing correctly when used in a method in my controller.
My Controller "A" is inheriting from Controller "B" and Controller "A" is overriding one of the method of Controller "B". I have my custom attribute applied to that method but it's not executing at all. I tried putting in the base method a开发者_如何转开发s well but still same.
As noted earlier, the custom attribute is executing as expected if applied in methods that is not overriding.
Am I missing anything?
Attribute is executed for the following action method:
[RequireAuthorizationFor(Operation.Create)]
public ViewResult New()
{
return View("Edit", new TermDateDto());
}
But not for the following:
[RequireAuthorizationFor(Operation.List)]
public override ViewResult List(Query query, int? pageNo)
{
return base.List(query, pageNo);
}
If it is a custom attribute, is it set to inherit = true?
[AttributeUsage(AttributeTargets.Method, Inherited = true)]
Also; perhaps side-step the issue; don't make the public attributed method virtual
- instead make it call a protected virtual
method. A little abstraction goes a long way.
精彩评论