I am using OWIN for authentication i want to inject BusinessService in AuthorisationServiceProvider how can we achieve it.
Asked
Active
Viewed 24 times
1 Answers
0
In your Startup.Auth.cs file, attach your ApplicationUserManager like below
app.CreatePerOwinContext(() => DependencyResolver.Current.GetService<ApplicationUserManager>());
And in your ApplicationUserManager use dependency injection to inject your business service like below
private readonly IBusinessService _businessService;
public ApplicationUserManager(IdentityRepository store, IBusinessService businessService) : base(store)
{
_businessService = businessService;
}
Finally, In your DependencyRegistrar.cs file, configure your resolcer as below
container.RegisterType<IAuthenticationManager>(new InjectionFactory(c => HttpContext.Current.GetOwinContext().Authentication));
container.RegisterType<IBusinessService, BusinessService>();

Ahmed Helmy
- 31
- 6
-
https://stackoverflow.com/questions/25997592/dependency-injection-using-simpleinjector-and-oauthauthorizationserverprovider?answertab=votes#tab-top – Neo123 Sep 03 '18 at 15:41