Strange behaviour with asp.net mvc action filters AttributeUsage

Viewed 4287

I have an action filter with the following signature

[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class UnitOfWorkAttribute : ActionFilterAttribute

According to MSDN:

The AllowMultiple property indicates whether multiple instances of your attribute can exist on an element. If set to true, multiple instances are allowed; if set to false (the default), only one instance is allowed.

In MVC the behaviour seems a bit strange. When I decorated an action with this attribute, I found that the OnActionExecuting method of the filter was executed twice.

The filter was only declared on the action, not on the controller, and I had cleared any global filters. Could someone explain this behaviour?

2 Answers
Related