We left Russia. We are against aggression and war with Ukraine. It is a tragedy for our nations, it is a nightmare

Using seperate IoC container from Asp.Net in AspNetCore

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