Is it possible to access ActionArguments
in an IExceptionFilter
?
According to the above picutre Exception Filters run after Action Filters which have access to them. So I don't see why they can't.
In an ActionFilter you access it like this
public class MyFilter : IActionFilter
{
public void OnActionExecuting(ActionExecutingContext context)
{
context.ActionArguments // I need access to this in order to find out what type the input argument(s) was.
}
}
But an IExceptionFilter uses public void OnException(ExceptionContext context)
instead.
I figured it out :)
public class ExceptionFilter : IExceptionFilter, IActionFilter
{
private IDictionary<string, object> _actionArguments;
public void OnException(ExceptionContext context)
{
_actionArguments // great success!
}
public void OnActionExecuting(ActionExecutingContext context)
{
_actionArguments = context.ActionArguments;
}
public void OnActionExecuted(ActionExecutedContext context)
{
// do nothing
}
}