/// <summary> /// 3、发生异常时 /// </summary> /// <param name="context">context</param> public void OnException(ExceptionContext context) { if (_isIgnore) { return; } _timer.Stop(); _logModel.LogType = (int)LogType.Exception; _logModel.Exception = context.Exception; _logModel.DurationTimeOfMillisecond = _timer.ElapsedMilliseconds.ToString().ToInt32(); _log.ErrorAsync(_logModel); context.HttpContext.Response.StatusCode = 500; context.HttpContext.Response.WriteAsync(context.Exception.Message); context.ExceptionHandled = true; }