Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Valdation message not showing

$
0
0

I am new to asp.net core lattest version and I am trying to get validation working on my register section but its not showing up on screen.

My Controller

    [HttpPost]
        public async Task<IActionResult> Login(string email, string password, bool rememberMe)
        {
            var user = await _userManager.FindByEmailAsync(email);
            if (user == null)
            {
                ModelState.AddModelError(string.Empty, "Invalid login");
                return View();
            }
            if (!user.EmailConfirmed)
            {
                ModelState.AddModelError(string.Empty, "Confirm your email first");
                return View();
            }

            var passwordSignInResult = await _signInManager.PasswordSignInAsync(user, password, isPersistent: rememberMe, lockoutOnFailure: false);

            if (!passwordSignInResult.Succeeded)
            {
                await _userManager.AccessFailedAsync(user);
                ModelState.AddModelError(string.Empty, "Invalid login");
                return View();
            }

            return View();
        }

<form asp-controller="Account" asp-action="Login" method="post"><div asp-validation-summary="All"></div><div class="form-group has-feedback"><input type="email" class="form-control" name="email" id="email" placeholder="Email"><span class="glyphicon glyphicon-envelope form-control-feedback"></span></div><div class="form-group has-feedback"><input type="password" class="form-control" name="password" id="password" placeholder="Password"><span class="glyphicon glyphicon-lock form-control-feedback"></span></div><div class="row"><div class="col-xs-8"><div class="checkbox icheck"><label><input type="checkbox" name="rememberMe" value="true"> Remember Me<input type="hidden" name="rememberMe" value="false" /></label></div></div><!-- /.col --><div class="col-xs-4"><button type="submit" class="btn btn-primary btn-block btn-flat">Sign In</button></div><!-- /.col --></div></form> 

Does anbody know what is going wrong the valdiation messages are declaired in code behind at

ModelState


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>