public async Task <IActionResult> Login(UserLoginViewModel usrLogin, string returnURL) { if (!ModelState.IsValid) { return(View(usrLogin)); } var respo = await _clientHelper.Authenticate("api/login", new { username = usrLogin.Username, password = usrLogin.Password }); if (respo.IsSuccessStatusCode) { dynamic result = respo.Content.ReadAsStringAsync().Result; var token = (JsonConvert.DeserializeObject <AuthenticationModel>(result)).Token; await _tokenManager.Authenticate(token); if (string.IsNullOrWhiteSpace(returnURL)) { return(RedirectToAction("Index")); } return(Redirect(returnURL)); } ModelState.AddModelError("error", "Invalid username or password."); return(View(usrLogin)); }