Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

HostEngine Start not setting HttpContext.ApplicationServices - uses default DI provider #337

Closed
@ghost

Description

I am returning a UnityServiceProvider from ConfigureServices and I can see that it is being set to the ApplicationServices property (above the HostingEngine.Start method in top right of image below), however the httpContext.ApplicationServices is null which causes it to use _services resulting in the default DI provider to be used. I see the DefaultControllerActivator retrieves the HttpContext.RequestServices (default provider) resulting in my HomeController not resolving IFoo as expected (line 104 left pane) since it is not using my UnityServiceProvider.

I am making assumptions based on the limited documentation available during internet research, but will be glad to blog the topic if I am missing something and you can elaborate...

UPDATED: My work around was to add the following line in HostEngine.Start() that sets RequestServices as follows:

                using (logger.BeginScope("Request Id: {RequestId}", requestIdentifier))
                {
                    // BillKrat.2015.08.23 - work around so DI container is used
                    httpContext.RequestServices = ApplicationServices;

                    contextAccessor.HttpContext = httpContext;
                    await application(httpContext);
                }

serviceprovider

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions