public async Task <ActionResult> EnrollSmsAsync(EnrollSmsViewModel model) { if (!ModelState.IsValid) { return(View("EnrollSms", model)); } var enrollOptions = new EnrollSmsFactorOptions() { PhoneNumber = model.PhoneNumber, StateToken = Session["stateToken"].ToString(), }; try { var authnResponse = await _oktaAuthenticationClient.EnrollFactorAsync(enrollOptions).ConfigureAwait(false); if (authnResponse.AuthenticationStatus == AuthenticationStatus.MfaEnrollActivate) { Session["factorId"] = authnResponse.Embedded.GetProperty <Factor>("factor").Id; return(RedirectToAction("VerifyFactor", "Manage")); } throw new NotImplementedException($"Unhandled Authentication Status {authnResponse.AuthenticationStatus}"); } catch (Exception exception) { ModelState.AddModelError(string.Empty, exception.Message); return(View("EnrollSms", model)); } }