public async Task <IActionResult> SignUp(RegistrationModel register) { if (ModelState.IsValid) { register.profile.login = register.profile.email; OktaHelper oktaHelper = new OktaHelper(_Config); var result = await oktaHelper.CreateUser(register); if (result.IsSuccessStatusCode) { var user = oktaHelper.GetJsonObject(result); var activationLink = $"{Request.Scheme}://{Request.Host}/ACRLoginPortal/Account/Activate?userID={user["id"].Value<string>()}&key={register.Key}"; //Body = $"<p>Hi {register.profile.firstName},<br/><br/>Welcome to American College of Radiology!<br/><br/>To verify your email address and activate your account,please click the following link: <br/> <a href = \"{Request.Scheme}://{Request.Host}/Account/Activate?userID={user["id"].Value<string>()}&key={register.Key}\">Activate Account</a></p>", EmailModel email = new EmailModel { Body = EmailService.AccountActivationEmailBody(register.profile.firstName, activationLink), Subject = $"Activation URL", IsHtml = true, To = new List <string>() { user["profile"]["email"].Value <string>() }, SMTPServer = _Config.Value.SMTP_Server, SMTPPort = Convert.ToInt32(_Config.Value.SMTP_Port), SMTPUser = _Config.Value.SMTP_Username, SMTPPassword = _Config.Value.SMTP_Password, EnableSsl = _Config.Value.SMTP_EnableSSl }; EmailService.SendEmail(email); //TempData["Message"] = "Account created successfully. The account activation link has been sent to your email address. Please check the inbox."; return(RedirectToAction("SignUpMessage", "Registration", new { key = register.Key, status = "success" })); } else { var error = oktaHelper.GetJsonObject(result); ModelState.AddModelError("Error", error["errorCauses"][0]["errorSummary"].Value <string>()); return(View($"~/Views/Registration/SignUp.cshtml", register)); } } else { ModelState.AddModelError("Error", "Sorry, we found some errors.Please review the form and make corrections."); return(View($"~/Views/Registration/SignUp.cshtml", register)); } }