Why does the console display validation errors but ValidationSummary does not display them? How to make ValidationSummary display User Validation failed?
If you want to see the error in the view, you can add below code in your Register action .
[HttpPost]
public async Task<ActionResult> Register(RegisterViewModle modle)
{
if (!ModelState.IsValid) { return View(modle); }
var user = new ApplicationUser { Email = modle.Email, UserName = modle.Name };
var result = await _UserManeger.CreateAsync(user, modle.Pasword);
var roleResult = await _UserManeger.AddClaimAsync(user, new Claim(ClaimTypes.Role, "User"));
if (result.Succeeded & roleResult.Succeeded)
{
await _SignInManager.SignInAsync(user, isPersistent:false);
return Redirect("https://localhost:7195/user");
}
foreach (var error in result.Errors)
{
ModelState.AddModelError(string.Empty, error.Description);
}
return View(modle);
}
Result: