-
Notifications
You must be signed in to change notification settings - Fork 25.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add claims to Identity using IUserClaimsPrincipalFactory - subtopic generates run-time errors. #18797
Comments
I just went through this tutorial. I found that the code in the section cited is out-of-context for the rest of the topic. Up until that point, it's a step-by-step tutorial. In that section, it's more "example code" than it is a step in the tutorial. For example, the tutorial part is all about Having followed the tutorial, what you should do is:
|
Serpent5 - Thanks for the confirmation that I haven't gone crazy. What I think I really need is separate roles, so I will forget the out-of-context stuff and move on. |
@Rick-Anderson What should we do with this one? Here's a few ideas:
|
How about 2 and keep it simple buy adding, For more information, see `this GitHub issue |
This is just feedback of my experience of the chosen solution (2)... It's really odd that Add claims to Identity using IUserClaimsPrincipalFactory doesn't follow on from the step-by-step tutorial. It's completely out of place and has nothing to do with the subject of the page. The I would expect this section to add either the |
@serpent5 please review previous comment. I think we should just remove this section. |
I agree. I'll do that now. |
[Enter feedback here]
I am using Net Core 3.1.6.
I worked through this tutorial page successfully up to the topic cited in the title.
With the WebApp1 project built as instructed, runtime produces the error:
System.InvalidOperationException: 'Scheme already exists: Identity.Application'
I worked out that this was due to there being two calls to establish Identity: one in Startup.cs, and one in IdentityHostingStartup.cs.
Commenting out the one in IdentityHostingStartup.cs produces:
InvalidOperationException: No service for type 'Microsoft.AspNetCore.Identity.UserManager`1[WebApp1.Areas.Identity.Data.WebApp1User]' has been registered.
Commenting out the one in Startup.cs produces:
System.AggregateException: 'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Identity.IUserClaimsPrincipalFactory
1[WebApp1.Areas.Identity.Data.ApplicationUser] Lifetime: Scoped ImplementationType: WebApp1.Areas.Identity.Data.AdditionalUserClaimsPrincipalFactory': Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UserManager
1[WebApp1.Areas.Identity.Data.ApplicationUser]' while attempting to activate 'WebApp1.Areas.Identity.Data.AdditionalUserClaimsPrincipalFactory'.)'It seems I need to construct a call which uses some things from one of the calls, and some things from the other, but I can't find in the docs a clear list of the services which should be registered.
I realise this is not a "help" service. It would be nice, however, if the tutorial provided a working sample.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: