Identityserver4: Startup Issue When Using AddAspNetIdentity

Created on 13 Jun 2018  路  2Comments  路  Source: IdentityServer/IdentityServer4

I am using IdentityServer4 with ASP.NET Core 2.1 with Visual Studio 2017. I try to integrate ASP.net Identity, but I get this exception during startup: "IUserClaimsPrincipalFactory`1 not registered."

Relevant parts of the log file

2018-06-13 22:04:30.411 +07:00 [FTL] Application startup exception
System.InvalidOperationException: Service type: IUserClaimsPrincipalFactory`1 not registered.
   at Microsoft.Extensions.DependencyInjection.IdentityServerBuilderExtensions.AddDecorator[TService](IServiceCollection services)
   at Microsoft.Extensions.DependencyInjection.IdentityServerBuilderExtensions.AddTransientDecorator[TService,TImplementation](IServiceCollection services) in C:\local\identity\server4\AspNetIdentity\src\IdentityServer4.AspNetIdentity\IdentityServerBuilderExtensions.cs:line 62
   at Microsoft.Extensions.DependencyInjection.IdentityServerBuilderExtensions.AddAspNetIdentity[TUser](IIdentityServerBuilder builder) in C:\local\identity\server4\AspNetIdentity\src\IdentityServer4.AspNetIdentity\IdentityServerBuilderExtensions.cs:line 33
   at OsjaSolutions.IdentityServer.Startup.ConfigureServices(IServiceCollection services) in C:\PROJECT\OsjaSolutions\Backend\IdentityServer\Startup.cs:line 42
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

Most helpful comment

I found the issue. I get this exception because I did not add the following line in ConfigureServicesfunction (Startup.cs)

services.AddIdentity<ApplicationUser, IdentityRole>().AddEntityFrameworkStores<ApplicationDbContext>().AddDefaultTokenProviders();

All 2 comments

I found the issue. I get this exception because I did not add the following line in ConfigureServicesfunction (Startup.cs)

services.AddIdentity<ApplicationUser, IdentityRole>().AddEntityFrameworkStores<ApplicationDbContext>().AddDefaultTokenProviders();

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leksim picture leksim  路  3Comments

eshorgan picture eshorgan  路  3Comments

user1336 picture user1336  路  3Comments

krgm03 picture krgm03  路  3Comments

mackie1001 picture mackie1001  路  3Comments