Building on the answer from @Pankaj and comments from @csetzkorn:
You pass the name of the parameter as a string then check the filterContext
public class NewAuthoriseAttribute : ActionFilterAttribute
{
public string IdParamName { get; set; }
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (filterContext.ActionParameters.ContainsKey(IdParamName))
{
var id = filterContext.ActionParameters[IdParamName] as Int32?;
}
}
}
[NewAuthorizeAttribute(IdParamName = "fooId")]
public ActionResult Index(int fooId)
{ ... }