Controllers/AccountController.cs
/// <summary>
/// Action associated with submitting the login form
/// </summary>
/// <param name="model">
/// The view model containing the username and password
/// entered by the user
/// </param>
/// <returns>Http response to a POST Request</returns>
Action associated with submitting the login form
Action associated with submitting the login form
[HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        public async Task<IActionResult> Login(LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                var result = await _signInManager.PasswordSignInAsync(model.Username, model.Password, false, lockoutOnFailure: false);
                if (result.Succeeded)
                {
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Invalid login attempt.");
                    return View(model);
                }
            }
            return View(model);
        }
[ HttpPost ] [ AllowAnonymous ] [ ValidateAntiForgeryToken ] public async Task < IActionResult > Login ( LoginViewModel model ) { if ( ModelState . IsValid ) { var result = await _signInManager . PasswordSignInAsync ( model . Username , model . Password , false , lockoutOnFailure : false ) ; if ( result . Succeeded ) { return RedirectToAction ( " " , " " ) ; } else { ModelState . AddModelError ( string . Empty , " " ) ; return View ( model ) ; } } return View ( model ) ; }
Action associated with submitting the login form
Action associated with submitting the login form
Http response to a POST Request
Http response to a POST Request
model
LoginViewModel
The view model containing the username and password
entered by the user
The view model containing the username and password entered by the user