public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { await HttpContext.SignOutAsync(); return(Page()); } ActionResult response = Page(); try { var resultado = await checkInService.Login(Input.Email, Input.Password, Input.CedulaJuridica); string str = ""; foreach (var item in resultado.Seguridad) { str += item.CodModulo + "|"; } var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme); identity.AddClaim(new Claim(ClaimTypes.Name, resultado.Email)); identity.AddClaim(new Claim(ClaimTypes.UserData, resultado.token)); identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, resultado.CedulaJuridica)); identity.AddClaim(new Claim(ClaimTypes.Actor, resultado.idLogin.ToString())); identity.AddClaim(new Claim(ClaimTypes.Role, resultado.idRol.ToString())); identity.AddClaim(new Claim("Roles", str)); identity.AddClaim(new Claim("Logo", resultado.UrlLogo)); identity.AddClaim(new Claim("CambiarClave", resultado.CambiarClave.ToString())); identity.AddClaim(new Claim("Pais", resultado.Pais.ToString())); var principal = new ClaimsPrincipal(identity); await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal); if (resultado.CambiarClave) { return(RedirectToPage("/Account/CambioContrasena")); } return(RedirectToPage("/Liquidaciones/Index")); } catch (ValidationApiException) { // handle validation here by using validationException.Content, // which is type of ProblemDetails according to RFC 7807 // If the response contains additional properties on the problem details, // they will be added to the validationException.Content.Extensions collection. } catch (ApiException exception) { if (exception.StatusCode == System.Net.HttpStatusCode.BadRequest) { Errores error = JsonConvert.DeserializeObject <Errores>(exception.Content.ToString()); ModelState.AddModelError("Email", error.Message); return(Page()); } } catch (Exception ex) { ModelState.AddModelError("Email", ex.Message); return(Page()); } return(response); }