Asp-validation-summary in view shows errors added via ModelState.AddModelError, but don't show any model validation errors ("The User field is required."). I'm using Microsoft.AspNetCore.Mvc 1.0.0-rc2-final. Btw: User field is not displayed via the view but correctly identified by EF as a model level error before add.
//<div asp-validation-summary="ModelOnly" class="text-danger"></div> in view
ModelState.AddModelError(string.Empty, "This error shows up in validation-summary");
ViewBag.HeaderMessage = "Error: " + string.Join(" - ", ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage));
Errors show in field filled via ViewBag but not in validation-summary
Change your html:
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
to
<div asp-validation-summary="All" class="text-danger"></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With