Closed brianlocke closed 7 years ago
Let me know if this isn't the correct place to put this.
This is a question for stackoverflow.
Can we get a link to the answer at least?
@omayhemo I think this is the link: http://stackoverflow.com/questions/42441771/user-identity-name-is-always-null-when-using-aspnetidentity-with-identityserver3
But it doesn't have an answer yet :(
Yeah, my solution was to put something like this:
((ClaimsPrincipal)HttpContext.Current.User).FindFirst("sub").Value,
Thanks CesarD, I have already implemented a solution, I should've revisited here to share.
If you want to use some of the inherited methods in the Microsoft.AspNet.Identity.UserManager to pull useful claims (such as UserId) and make as few changes as possible to ASP.net Identity Integrations
That'll wire up what ASP.net Identity expect to find using the canned functionality. For example from a MVC controller User.Identity.GetUserId() and the OP original question.
I updated my question on the stackoverflow link to say that I continued to manually add the claim. I haven't had the time to dig into why the two sample projects behave differently. Apologies for not keeping up with my own question!
I've been trying to setup a new IdentityServer3 with AspNetIdentity for a few days now. I'm able to login using my existing Identity DB and that's all good but I can never get the User.Identity.Name to contain data. I've tried multiple attempts at adding custom claims & scopes and adding scopes to clients.
Finally, I loaded up the sample repository and tested it out with the webforms sample since it already used the User.Identity.Name in it's About page.
Using WebForms sample client + AspNetIdentity sample server = User.Identity.Name is always null Using WebForms sample client + SelfHost with Seq sample server = User.Identity.Name with data
Let me know if this isn't the correct place to put this.