How to skip action execution from an ActionFilter?
action-filter, asp.net-mvc
Solution
You can use filterContext.Result for this. It should look like this:
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
//Check your condition here
if (true)
{
//Create your result
filterContext.Result = new EmptyResult();
}
else
base.OnActionExecuting(filterContext);
}
Problem
Is it possible to skip the whole action method execution and return a specific `ActionResult` when a certain condition is met in `OnActionExecuting`?