how I can parse List into me custom action filter (like input parameters) ?
public class CustomFilter : ActionFilterAttribute
{
    public List<MyEnumType> InputParameter { get; set; }
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {         
        base.OnActionExecuting(filterContext);
    }
}
[CustomFilter(InputParameter = new List<MyEnumType>() { MyEnumType.Type } )]
public SomeActionInController()
{
}
I got errror Error
'InputParameter' is not a valid named attribute argument because it is not a valid attribute parameter type
                Action filter parameters are properties of the action filter:
[CustomFilter(InputParameter=10)]
public SomeActionInController()
{
}
public class CustomFilter : ActionFilterAttribute
{
  public int InputParameter { get; set; }
  public override void OnActionExecuting(ActionExecutingContext filterContext)
  {
    // access this.InputParameter
    base.OnActionExecuting(filterContext);
  }
}
Attribute parameter types are limited to the types described here - http://msdn.microsoft.com/en-us/library/aa664615%28v=vs.71%29.aspx
You can pass a collection via the attributes constructor as described here - Can I initialize a C# attribute with an array or other variable number of arguments?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With