public async Task Invoke(HttpContext context) { try { await _next(context); } catch (Exception ex) { McsWebHelper.LogWebError(_product, _layer, ex, context); PathString originalPath = context.Request.Path; if (_options.ExceptionHandlingPath.HasValue) { context.Request.Path = _options.ExceptionHandlingPath; } context.Response.Clear(); var exceptionHandlerFeature = new ExceptionHandlerFeature() { Error = ex, Path = originalPath.Value, }; context.Features.Set <IExceptionHandlerFeature>(exceptionHandlerFeature); context.Features.Set <IExceptionHandlerPathFeature>(exceptionHandlerFeature); context.Response.StatusCode = 500; context.Response.OnStarting(_clearCacheHeadersDelegate, context.Response); await _options.ExceptionHandler(context); return; } }
public override void OnActionExecuted(ActionExecutedContext context) { var dict = new Dictionary <string, object>(); foreach (var key in context.RouteData.Values?.Keys) { dict.Add($"RouteData-{key}", (string)context.RouteData.Values[key]); } McsWebHelper.LogWebUsage(_product, _layer, _activityName, context.HttpContext, dict); }
public void OnActionExecuting(ActionExecutingContext context) { var request = context.HttpContext.Request; var activity = $"{request.Path}-{request.Method}"; var dict = new Dictionary <string, object>(); foreach (var key in context.RouteData.Values?.Keys) { dict.Add($"RouteData-{key}", (string)context.RouteData.Values[key]); } var details = McsWebHelper.GetWebLogDetail(_product, _layer, activity, context.HttpContext, dict); _tracker = new PerfTracker(details); }