Assume I have a controller method like this:
[Audit]
public JsonNetResult List(int start, int limit, string sort, string dir, string searchValue, SecurityInputModel securityData)
{
...
}
and an attribute defined as such:
[AttributeUsage(AttributeTargets.Method)]
public class AuditAttribute : ActionFilterAttribute
{
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
// auditing code here
base.OnActionExecuted(filterContext);
}
}
can I get at the value of start/limit/sort/etc from inside OnActionExecuted()?
You can get the parameter values in
OnActionExecutingusing the ActionExecutingContext.ActionParameters property.For example, the following test attribute writes the parameter names and values out to the response (the
ItemModelclass overridesToStringto just output its 2 properties):