tags:

views:

50

answers:

1

when overriding OnActionExecuting, how do I return a Json result without passing to action?

+5  A: 
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
   if (/* whatever */)
   {
      var result = new JsonResult();
      result.Data = /* json data */;
      filterContext.Result = result;
      return;
   }

   base.OnActionExecuting(filterContext);
   return;
}
womp
ok how to insert json data here thanks
zsharp
Set the Data property of the result to the Json data that you want to return.
womp