views:

99

answers:

1

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 as 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);
    }
+1  A: 

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.

Marc Gravell
hi marc, i have updated the question with code sample. thanks
ashik_gurung
i tried by setting Inherited = true but to no avail :-(
ashik_gurung