Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 允许来自同一电子邮件地址的多个帐户WEB API ASP.NET标识_C#_Asp.net_Asp.net Web Api_Asp.net Identity_Identity - Fatal编程技术网

C# 允许来自同一电子邮件地址的多个帐户WEB API ASP.NET标识

C# 允许来自同一电子邮件地址的多个帐户WEB API ASP.NET标识,c#,asp.net,asp.net-web-api,asp.net-identity,identity,C#,Asp.net,Asp.net Web Api,Asp.net Identity,Identity,我想使用asp.net identity framework创建多个具有相同电子邮件地址和不同用户名的用户 可能吗 当我尝试创建具有相同电子邮件地址的用户时,会出现此错误 { "message": "The request is invalid.", "modelState": { "": [ "Email 'tester123@live.com' is already taken." ] } } 您可以配置UserManager的UserValidat

我想使用asp.net identity framework创建多个具有相同电子邮件地址和不同用户名的用户

可能吗

当我尝试创建具有相同电子邮件地址的用户时,会出现此错误

{
  "message": "The request is invalid.",
  "modelState": {
    "": [
      "Email 'tester123@live.com' is already taken."
    ]
  }
}

您可以配置
UserManager
UserValidator
RequireUniqueEmail=false
。带有单个用户帐户的默认MVC5示例代码:

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;
}

您可以配置
UserManager
UserValidator
RequireUniqueEmail=false
谢谢。你节省了我的时间。我已经覆盖了UserManager类和boom。谢谢。请不要在你的帖子中添加乞讨。我已经编辑过一次了,现在您已经回滚了,我将请版主看一下。也
public ApplicationUserManager(IUserStore<ApplicationUser> store) : base(store)
{
    UserValidator = new UserValidator<ApplicationUser>(this)
    {
        AllowOnlyAlphanumericUserNames = false,
        RequireUniqueEmail = true
    };
 }