I have an asp.net core MVC project. I have an action to check if the email given by the user is existing or not? but it doesn`t show my ModelError message ?? anyone can help?
this is my Action :
[Route("/VerifyEmail")]
public IActionResult VerifyEmail()
{
return View();
}
[Route("/VerifyEmail")]
[HttpPost]
public IActionResult VerifyEmail(VerifyEmailViewModel verifyEmail)
{
if (!ModelState.IsValid)
{
return View(verifyEmail);
}
if (!_userService.IsExistEmail(verifyEmail.Email))
{
ModelState.AddModelError("Email", " ایمیل وارد شده معتبر نیست");
return View(verifyEmail);
}
var currentUser = _userService.GetUserByEmail(verifyEmail.Email);
return View("/Views/Account/SuccessEmail.cshtml", currentUser);
}
and this is my Razore View :
@model GameShop.Data.Domain.ViewModels.VerifyEmailViewModel
<div class="row">
<div class="col-md-12">
<form action="/VerifyEmail" method="POST">
<div class="form-group">
<label asp-for="Email" class="control-label"></label>
<input asp-for="Email" class="form-group" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="ارسال" class="btn btn-success" />
</div>
</form>
</div>
</div>
@section Scripts{
@{await Html.RenderPartialAsync("_ValidationScriptsPartial.cshtml");}
}