I'm customizing IdentityServer4
UI to use Angular, I created SecurityController
with the constructor:
public SecurityController(
MyDbContext dbContext,
UserManager<IdentityUser> userManager,
AbpSignInManager signInManager
)
{
_dbContext = dbContext;
_userManager = userManager;
_signInManager = signInManager;
}
I'm getting the following exception when I refer to localhost:[port]/Security/[any action]
:
DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Acme.[ProjectName].Controllers.SecurityController' can be invoked with the available services and parameters: Cannot resolve parameter 'Microsoft.AspNetCore.Identity.UserManager
1[Microsoft.AspNetCore.Identity.IdentityUser] userManager' of constructor 'Void .ctor(Acme.[ProjectName].EntityFrameworkCore.MyDbContext, Microsoft.AspNetCore.Identity.UserManager
1[Microsoft.AspNetCore.Identity.IdentityUser], Volo.Abp.Identity.AspNetCore.AbpSignInManager)'.
P.S. If I remove UserManager
dependency it works.
Any Idea?
EDIT:
Here's my Startup.cs
:
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddApplication<MyIdentityServerModule>();
services.AddControllers();
}
public void Configure(IApplicationBuilder app)
{
app.InitializeApplication();
app.UseStatusCodePagesWithRedirects("~/index.html");
}
}
And here's MyIdentityServerModule
:
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
...
app.UseRouting();
...
app.UseAuthentication();
...
app.UseIdentityServer();
app.UseAuthorization();
...
}
I'm not familiar with
IdentityServer
, but theUserManager
class is part of the ASP.NET Identity middleware, and must be registered:You can check the
IdentityServer
quickstart guide for ASP.NET Core for more information.