Closed scottbrady91 closed 9 years ago
Can you point me to a change or reasoning?
Nothing particular. Is this still an open issue. Brock has a sample on how to use ASP.NET Identity in identity server - since nothing has happened here for 2 months - I thought it is OK to close this issue.
No, the above still applies. No changes since I created the issue.
I've seen a few people complaining about the IdentityServer (and IdentityManager) handling of ASP.NET Identity dependency injection. The issues arise from the handling of their generics and the ASP.NET teams recommendations of creating static create methods or pointlessly extending the base classes to hide the generics away, don't really help the situation.
The only way I've been able to get the DI working with the default Identity classes so far is like so:
Otherwise you will get the following error when autofac tries to resolve the UserService, as it cannot resolve the UserManager constructor:
Note that if I do not explicitly state the key in the UserManager registration, the resolver will again start throwing the above error.
As you can see from my factory set up, by the time I set up the DbContext to receive a connection string, I might as well have created my own concrete factory method and feed this into the DI component directly. But I don't really feel comfortable recommending this to people when you have gone out of your way to create the component...
I know the DI and generics situation in ASP.NET Identity itself is pretty dire, but there are ways around it when you have control over the DI container (autofac or otherwise).
If there's some reason I shouldn't be using the base Identity classes that I don't know of do say, but even if I extended them I would still aim to keep the generic types from the base classes...