Код: Выделить всё
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public class MyActionFilterAttribute : ActionFilterAttribute
{
public bool MyProperty {get; set;}
public MyActionFilterAttribute(bool myProperty = true)
{
MyProperty = myProperty;
}
public override void OnActionExecuting(HttpActionContext actionContext)
{
if(MyProperty)
{
//DO Something
}
}
}
Код: Выделить всё
config.Filters.Add(new CustomValidatorFilterAttribute());
Код: Выделить всё
[OverrideActionFilters]
[MyActionFilterAttribute(myProperty: false)]
public IHttpActionResult MyCation()
{
//Some staff here
}
Спасибо за помощь.
Подробнее здесь: https://stackoverflow.com/questions/537 ... ion-filter
Мобильная версия