Why does the console display validation errors but ValidationSummary does not display them? How to make ValidationSummary display User Validation failed?
RegisterView Code
@Html.ValidationSummary()
<h4>Name</h4>
@Html.TextBoxFor(model => model.Name)
<h4>Email</h4>
@Html.TextBoxFor(model => model.Email)
<h4>Pasword</h4>
@Html.TextBoxFor(model => model.Pasword)
<h4>ConfirmPasword</h4>
@Html.TextBoxFor(model => model.ConfirmPasword)
<h4>RememberMe</h4>
@Html.CheckBoxFor(model => model.RememberMe)
<button type="submit">Register</button>
photo of the Controller
Controller code
[HttpPost("Register")]
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");
}
return View(modle);
}