尝试将默认最小密码长度更改为4个字符.我知道,4!可笑,对!不是我的电话
无论如何,我已经在Registerviewmodel上更改了它,但实际上并没有改变它.为了说明我已经发布了下面的代码. ModleState.IsValid根据更新的viewmodel正确返回.然后它调用UserManager.CreateAsync()返回False,并显示一条错误消息“密码必须至少为6个字符”
我已经遵循了这个非常类似的帖子(Change Password…)中的步骤,但是对于MVC 5而言,它不起作用.它仍然返回相同的消息.
// // POST: /Account/Register [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<ActionResult> Register(Registerviewmodel model) { if (ModelState.IsValid) { var user = new ApplicationUser() { UserName = model.UserName,LastLogin = model.LastLogin }; // This is where it 'fails' on the CreateAsync() call var result = await UserManager.CreateAsync(user,model.Password); if (result.Succeeded) { await SignInAsync(user,isPersistent: false); return RedirectToAction("Index","Home"); } else { AddErrors(result); } } // If we got this far,something Failed,redisplay form return View(model); }