I am using asp.net Identity 2.0 to login to my site where authentication data is stored in an SQL database. Asp.net authentication was implemented in a standard way, as can be found in many online tutorials.
The ApplicationUser
class in IdentityModels
been extended to include a custom property:
public class ApplicationUser : IdentityUser { public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager, string authenticationType) { CookieAuthenticationOptions.AuthenticationType var userIdentity = await manager.CreateIdentityAsync(this, authenticationType); return userIdentity; }
When I register a new user, I pass the Code
custom property to RegisterBindingModel
, but I'm not sure how to insert this custom property into the WebUsers table.
I did this below, but in fact it does not insert this property into the table along with the username and password.
var user = new ApplicationUser() { UserName = userName, Email = model.Email, Code=model.Code };
And the whole function:
[AllowAnonymous] [Route("Register")] public async Task<IHttpActionResult> Register(RegisterBindingModel model) { if (!ModelState.IsValid) { return BadRequest(ModelState); } var userName = !string.IsNullOrEmpty(model.UserName) ? model.UserName : model.Email;
What am I missing? I looked at similar questions, but could not find an answer for this.
source share