I have been trying to install a new IdentityServer3 with AspNetIdentity for several days. I can log in using my existing Identity database, and that is fine, but I can never force User.Identity.Name to contain data. I tried several attempts to add custom requests and areas and add areas for clients.
Finally, I downloaded the IdentityServer3 test repository and tested it using the webforms client project, since it already used User.Identity.Name in it About page.
Using the WebForms + Client Example Sample Server Example AspNetIdentity = User.Identity.Name is always null .Identity.Name.
Now, on the client side, I wrote a workaround to get the value of the "preferred_username" request and give it a "name".
var id = new claimsIdentity(n.AuthenticationTicket.Identity.AuthenticationType); id.AddClaims(userInfoResponse.GetClaimsIdentity().Claims); //set the User.Identity.Name value var name = id.Claims.Where(x => x.Type == "name").Select(x => x.Value).FirstOrDefault() ?? id.Claims.Where(x => x.Type == "preferred_username").Select(x => x.Value).FirstOrDefault(); id.AddClaim(new Claim("name", name));
My questions:
- Why doesn't the AspNetIdentity package populate this by default?
- And what do I need to change on the server side so that I do not need to change the client?
source share