Using seperate IoC container from Asp.Net in AspNetCore

ioc-container
aspnetcore
Tags: #<Tag:0x00007f6a00d91950> #<Tag:0x00007f6a00d914f0>

#1

Well, let me give you basic example,

  1. I have an interface that holds current user, call it IUserContext,
  2. I have two implementations, WebUserContext, HangfireUserContext.
  3. WebUserContext uses httpcontext.current.user and HangfireUserContext uses some static field, it does not matter.
  4. I have failed to find a way to discriminate contains of aspnet and hangfire.

The things I have tried:

  1. GlobalConfiguration.Configuration.UseActivator(new MyActivator(services));
    Hangfire did not called my ActivateJob method.
  2. app.UseHangfireServer(new BackgroundJobServerOptions()
    {
    Activator = new MyActivator(services)
    });
    Hangfire did not called my ActivateJob method.

In both examples, Hangfire uses default IoC container which is registered&used by asp.net core