Store multiple User data in User Claim Table

asp.net-identity-2 asp.net-mvc asp.net-mvc-5 entity-framework-6

Question

I am using mvc 5, asp.net 4.5, EF 6 and identity 2.
I met a problem of inserting multiple user data into User Claim Tale In my controller, after successful user creation i have the below code

await UserManager.AddClaimAsync(user.Id, new Claim("FullName", user.FullName));

By this i can only insert FullName string in ClaimType column and user fullname in ClaimValue.
But i have insert FullName, Email and UserType and their respective values.

1
2
4/2/2016 8:43:44 AM

Accepted Answer

To add multiple claims you can just call AddClaimAsync for each claim you want to add:

await UserManager.AddClaimAsync(user.Id, new Claim("Email", user.Email));
await UserManager.AddClaimAsync(user.Id, new Claim("UserType", user.UserType));
3
3/1/2016 6:51:06 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow