本文介绍了Microsoft.AspNetCore.Identity.UserManager:警告:用户验证失败:InvalidUserName; InvalidEmail的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用UserName,FirstName和LastName和Email字段创建一个用户.我正在使用Mysql数据库和Pomelo软件包.迁移和数据库更新工作正常.
I need to create a user with UserName, FirstName and LastName and Email fields. I'm using Mysql database and Pomelo package. Migration and DB update are working fine.
此代码会导致失败.
public async Task<IActionResult> CreateUserAsync()
{
var user = new ApplicationUser(
UserName: "blablabla",
FirstName: "blablabla",
LastName: "blablabla",
Email: "blablabla@gmail.com"
);
var successful = await mUserManager.CreateAsync(user
, "Pasword123456#");
if(successful.Succeeded)
return Content("User was created", "text/html");
return Content("User created FAILED", "text/html");
}
}
数据库中的表为空
我不知道如何使它工作.
I have no idea how to make it work.
在调试模式下,这是我仅有的信息.
In debug mode that is the only information I have.
推荐答案
我发现了问题所在.
我正在覆盖ApplicationUser中的电子邮件和用户名.这是建筑物中的警告.
I was overwriting Email and UserName in ApplicationUser.This was the warning in the building.
解决方案就是删除字段.
The solution was simply removing the fields.
这篇关于Microsoft.AspNetCore.Identity.UserManager:警告:用户验证失败:InvalidUserName; InvalidEmail的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!