/// <summary> /// 执行 /// </summary> /// <param name="context">操作执行上下文</param> /// <param name="next">委托</param> /// <returns></returns> public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (next == null) { throw new ArgumentNullException(nameof(next)); } ActionFilterAttribute actionFilterAttribute = this; actionFilterAttribute.OnActionExecuting(context); await OnActionExecutingAsync(context); if (context.Result != null) { return; } var executedContext = await next(); actionFilterAttribute.OnActionExecuted(executedContext); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { principalFilter.OnActionExecuting(filterContext); Authenticate(filterContext); base.OnActionExecuting(filterContext); }
public override void OnActionExecuting(HttpActionContext actionContext) { _traceWriter.TraceBeginEnd( actionContext.Request, TraceCategories.FiltersCategory, TraceLevel.Info, _innerFilter.GetType().Name, ActionExecutingMethodName, beginTrace: (tr) => { tr.Message = Error.Format( SRResources.TraceActionFilterMessage, FormattingUtilities.ActionDescriptorToString( actionContext.ActionDescriptor)); HttpResponseMessage response = actionContext.Response; if (response != null) { tr.Status = response.StatusCode; } }, execute: () => { _innerFilter.OnActionExecuting(actionContext); }, endTrace: (tr) => { HttpResponseMessage response = actionContext.Response; if (response != null) { tr.Status = response.StatusCode; } }, errorTrace: (tr) => { HttpResponseMessage response = actionContext.Response; if (response != null) { tr.Status = response.StatusCode; } }); }
public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { ActionFilterAttribute actionFilterAttribute = this; if (context == null) { throw new ArgumentNullException(nameof(context)); } if (next == null) { throw new ArgumentNullException(nameof(next)); } actionFilterAttribute.OnActionExecuting(context); if (context.Result != null) { return; } var context1 = await next(); await ProcessODataQuery(context1); OnActionExecuted(context1); }