IdentityServer4
IdentityServer4 copied to clipboard
AddIdentityCore
Issue / Steps to reproduce the problem
This works:
services.AddDefaultIdentity<User>(options =>{
options.User.RequireUniqueEmail = true;
options.Stores.MaxLengthForKeys = 128;
})
.AddRoles<IdentityRole>()
.AddEntityFrameworkStores<AppDbContext>()
.AddSignInManager<SignInManager<User>>()
.AddDefaultTokenProviders();
This throws a nullreference exception in app.UseIdentityServer();
services.AddIdentityCore<User>(options =>{
options.User.RequireUniqueEmail = true;
options.Stores.MaxLengthForKeys = 128;
})
.AddRoles<IdentityRole>()
.AddEntityFrameworkStores<AppDbContext>()
.AddSignInManager<SignInManager<User>>()
.AddDefaultTokenProviders();
I looked into the source of AddDefaultIdentity
and its almost the same as AddIdentityCore
except that it adds cookies.
Relevant parts of the log file
IdentityServer4.dll!Microsoft.AspNetCore.Builder.IdentityServerApplicationBuilderExtensions.ValidateAsync(System.IServiceProvider services, Microsoft.Extensions.Logging.ILogger logger) C#
> IdentityServer4.dll!Microsoft.AspNetCore.Builder.IdentityServerApplicationBuilderExtensions.Validate(Microsoft.AspNetCore.Builder.IApplicationBuilder app) Line 54 C#
IdentityServer4.dll!Microsoft.AspNetCore.Builder.IdentityServerApplicationBuilderExtensions.UseIdentityServer(Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.IdentityServerMiddlewareOptions options) Line 19 C#
Project.dll!Project.Startup.Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IWebHostEnvironment env, Microsoft.AspNetCore.Identity.RoleManager<Microsoft.AspNetCore.Identity.IdentityRole> roleManager) Line 152 C#
IdentityServer4.Startup: Information: Using explicitly configured authentication scheme Identity.Application for IdentityServer
Exception thrown: 'System.NullReferenceException' in IdentityServer4.dll
Object reference not set to an instance of an object.
Brother, did you solve this problem, I also encountered it
Brother, did you solve this problem, I also encountered it
Yeah, was this ever solved???