I would like to use a variable to pass a dynamic value to my action filter. I thought it would be something like this:
[MessageActionFilter(message = "User is updating item: " & id)]
public ActionResult doSomething(int id)
{
// do something
}
However, it seems that the parameter must be a constant value. Therefore, my question is how do I get the variable to my action filter?
You can get the parameter values in OnActionExecuting using the ActionExecutingContext.ActionParameters property.
It’s just a pseudo code, but for example you can retrive the parameter named id
Tell me if it helps.