views:

286

answers:

1

I have a custom filter attribute that I want to use on certain ActionResults to look at the data being attempted and to set values where certain rules are violated.

So;

public class SpecialActionFilter : ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        foreach (string value in filterContext.Controller.ValueProvider.Keys)
        {
            string h = filterContext.Controller.ValueProvider[value].AttemptedValue;

            if (h == "1")
            {
                //set the value of the key to be say "one".    
            }
        }

        base.OnActionExecuting(filterContext);
    }

}

is this possible?

A: 

You can inspect or modify the parameters that will be passed to the action - see the ActionExecutingContext.ActionParameters property for this. This is a very general solution, though. If you could provide a little more context on what exactly you're trying to do, we might be able to provide more relevant suggestions.

Levi