当覆盖OnActionExecuting时,如何返回Json结果而不通过操作?
解决方法
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (/* whatever */) { var result = new JsonResult(); result.Data = /* json data */; filterContext.Result = result; return; } base.OnActionExecuting(filterContext); return; }