Is there any benefit to storing user information in AspNetUserClaims with Asp.Net Identity 2? -


I'd like to store some additional user information, what I think the following is a general option:

 < Code> Public class ApplicationUser: IdentityUser {public async works & lt; Identity of the claim & gt; GenerateUserIdentityAsync (UserManager & lt; ApplicationUser & gt; manager) Note: The authentication type should be defined in the cookie outption option. AuthenticationType var userIdentity = Wait Manager. // Add custom user claims here, return user identities; } Public string first name {receives; Set; } Public String LastName {get; Set; }}   

The first name and last name have been added here and they will appear as additional fields in the aspNetUsers table.

Although it seems that there is now an option to store such information in the aspNetUserClaims table with ASP.Net identification.

Can someone explain to me that going forward is such information that can be stored in espaƱenSquime? If so, then someone has an example of this

At the end of the day, your signed user claims Will be converted into a series of identifying claims representing your user in HttpContext.User.Identity. You can choose to store the first name / last name as the column in the user table, which you can read clearly and convert it to the appropriate claims (if desired), or you can directly them in the aspnetUserClaims table Can be stored as claims (which only stores them as two string columns) which by default will be used to identify your user's claims Will be added in the form. Both ways are more or less equivalent, so it depends on personal preference.

BTW is the only reason that you would want them to claim the user's claim, that is, you want to display only DB hits, and always claim FirstName / LastName in the identity of the claim. Use if you receive the user, and use the user. Instead of the first place, there is not a lot of value in generating the name claims.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -