public async Task Invoke(HttpContext httpContext) { var shellSettings = httpContext.RequestServices.GetService <ShellSettings>(); _shellHost.BeginRequest(shellSettings); httpContext.Response.Headers.Append("X-Generator", "Orchard"); await _next.Invoke(httpContext).ContinueWith(x => { _shellHost.EndRequest(shellSettings); }); }