# Using seperate IoC container from Asp.Net in AspNetCore

**URL:** <https://discuss.hangfire.io/t/using-seperate-ioc-container-from-asp-net-in-aspnetcore/4563>\
**Category:** question\
**Tags:** ioc-container, aspnetcore\
**Created:** [April 13, 2018, 8:11pm UTC](https://discuss.hangfire.io/t/using-seperate-ioc-container-from-asp-net-in-aspnetcore/4563 "2018-04-13T20:11:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oguzhan\_Topcu](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/oguzhan_topcu/32/1556_2.png) [@Oguzhan\_Topcu](https://discuss.hangfire.io/u/Oguzhan_Topcu)\
**Post date:** [April 13, 2018, 8:11pm UTC](https://discuss.hangfire.io/t/using-seperate-ioc-container-from-asp-net-in-aspnetcore/4563/1 "2018-04-13T20:11:37Z")

</div>

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](http://asp.net) core
