Actually, I would suggest a slightly different approach. The Identity team did what I consider a bit of a deadly sin when loading a sample using an OWIN-based impromptu dependency injection container. Injection injection is a great idea, but not like that. It is clear that different developers prefer different DI containers, which makes creating a standard project based on a real DI container a little bad, but they should refrain from using dependency injection in the sample project and just recommend using dependency injection and maybe instructions are given for implementing this with various containers.
All that was said, the only thing used by HttpContext is to get the OWIN context, and this in itself is used to handle their fading dependency injection for Identity. So, if you just enter your own UserManager with the selected DI container, you will remove the HttpContext dependency and you will be fine.
You just need to provide a configuration for two things: UserManager and IUserStore . Tell your DI container how to enter it, and then you can just add the dependency on UserManager to your library class constructor, and you're ready to go.
source share