Make RequestServicesContainerMiddleware the first middleware in the pipeline #653
Description
When we add a middleware through IStartupFilter, it will be added before RequestServicesContainerMiddleware in the pipeline (see the impl at https://github.com/aspnet/Hosting/blob/dev/src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs#L163) Therefore, the middleware won't be able to get any scoped service instance from HttpContext.RequestServices since RequestServices is not constructed by RequestServicesContainerMiddleware yet at the moment.
This could be fixed by ensuring RequestServicesContainerMiddleware always to be the first middleware in the pipeline. A possible fix is to move https://github.com/aspnet/Hosting/blob/dev/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs#L202 to https://github.com/aspnet/Hosting/blob/dev/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs#L218.
For more context and details, check out weidazhao/Hosting#8.