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
2010-04-20 20:22:51
ok how to insert json data here thanks
zsharp
2010-04-20 21:15:23
Set the Data property of the result to the Json data that you want to return.
womp
2010-04-20 21:29:04