我试图将userId
存储在AspNetUsers
表中,并在注册过程中将其存储在我的Student
表中。
如何从userId
表中获取新创建的用户{<1}}(不是登录用户),并将其存储在单独的表格中在注册过程中?
我的控制器:
AspnetUsers
答案 0 :(得分:0)
如果您创建了用户,则会自动为您创建ID。
var objNewAdminUser = new ApplicationUser { UserName = UserName, Email = Email};
var userId = objNewAdminUser.Id //18479b0a-17cd-4a76-9e9e-d90a8480617b
答案 1 :(得分:0)
you can try this
if(AdminUserCreateResult.Succeeded == true)
{
//Get Details of currently registered User
var RegisteredUser= SignInManager.UserManager.FindByEmail(Email);
//Extract userid from user Details.
var userid=RegisteredUser.Id;
//this will give you the ID stored in aspnetusers of currentUser
}