我想使用具有相同电子邮件地址和不同用户名的asp.net身份框架创建多个用户。
有可能吗?
当我尝试使用相同的电子邮件地址创建用户时,我收到此错误
{
"message": "The request is invalid.",
"modelState": {
"": [
"Email 'tester123@live.com' is already taken."
]
}
}
答案 0 :(得分:3)
您可以配置UserValidator
的{{1}}:UserManager
。具有个人用户帐户的默认MVC5的示例代码:
RequireUniqueEmail = false
您可能需要在public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context)
{
var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<ApplicationDbContext>()));
// Configure validation logic for usernames
manager.UserValidator = new UserValidator<ApplicationUser>(manager)
{
AllowOnlyAlphanumericUserNames = false,
RequireUniqueEmail = false
};
...
return manager;
}
类构造函数中设置它:
ApplicationUserManager