我刚刚将我的代码从 Identity 1.0.0 完全迁移到 2.0.0 & 由于某种原因,我遇到了一个奇怪的问题。尝试创建用户时,失败。错误是:电子邮件不能为空或为空。(当然,我将有效的电子邮件插入到该属性中)。请帮忙..
控制器.cs
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Register(RegisterViewModel model)
{
if (ModelState.IsValid)
{
var user = new ApplicationUser()
{
UserName = model.UserName,
contact_firstname = model.contact_firstname,
contact_lastname = model.contact_lastname,
Email = model.Email,
PhoneNumber = model.PhoneNumber,
contact_phone2 = model.contact_phone2,
street = model.street,
city = model.city,
country = model.country,
state = model.state,
postcode = model.postcode,
longitude = model.longitude,
latitude = model.latitude
};
var result = await UserManager.CreateAsync(user, model.Password);
//HERE IS THE ERROR
if (result.Succeeded)
{
string …Run Code Online (Sandbox Code Playgroud)