Implemented a custom service class derived from IProfileService. The custom impl of GetProfileDataAsync is not getting called. Can somebody tell me what is being done wrong or what needs to be done?
I have the following in startup
.AddProfileService<IdentityWithAdditionalClaimsProfileService>()
.SetSigningCredential(cert)
.AddOperationalStore(builders => builders.UseSqlServer(connectionString,
options => options.MigrationsAssembly(migrationsAssembly)))
.AddConfigurationStore(builders => builders.UseSqlServer(connectionString,
options => options.MigrationsAssembly(migrationsAssembly)))
.AddAspNetIdentity<ApplicationUser>();
Thanks
On further investigation looks like the constructor of the custom service is not getting called. I am also adding a TransientService for the custom user service.
services.AddTransient<IProfileService, IdentityWithAdditionalClaimsProfileService>();
inspect the IServiceCollection at the the end of ConfigureServices to make sure your implementation is in the container.
@leastprivilege why my profile service not added in container by services.AddProfileService call?
In my case switching the places of .AddProfileService<TService>() and .AddAspNetIdentity<TUser>() solved the problem.
So instead of:
.AddProfileService<IdentityProfileService>();
.AddAspNetIdentity<ApplicationUser>();
Declare
.AddAspNetIdentity<ApplicationUser>();
.AddProfileService<IdentityProfileService>();
In my case switching the places of
.AddProfileService<TService>()and.AddAspNetIdentity<TUser>()solved the problem.
I don't know how you stumbled into figuring that out but bless you for it, you just stopped my bleeding at two hours of wasted time.
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.
Most helpful comment
In my case switching the places of
.AddProfileService<TService>()and.AddAspNetIdentity<TUser>()solved the problem.So instead of:
.AddProfileService<IdentityProfileService>();.AddAspNetIdentity<ApplicationUser>();Declare
.AddAspNetIdentity<ApplicationUser>();.AddProfileService<IdentityProfileService>();