public ErrorContextInitializationMiddleware(RequestDelegate next, IHostApplicationLifetime lifetime) { _next = next; lifetime.ApplicationStarted.Register(() => ErrorContext.CreateNewErrorContext()); }