public IActionResult Registration(RegistrationRequest model) { RegistrationResponse resp = _AccountManagementService.Registration(model); if (resp.email_address == null) { return(Ok()); } else { System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(); mail.To.Add(resp.email_address); mail.From = new MailAddress(email.email_username, email.email_name, System.Text.Encoding.UTF8); mail.Subject = "This mail is send from asp.net application"; mail.SubjectEncoding = System.Text.Encoding.UTF8; mail.Body = "<a href='" + url.name + "/login/" + resp.id + "' > button </a>"; mail.BodyEncoding = System.Text.Encoding.UTF8; mail.IsBodyHtml = true; mail.Priority = MailPriority.High; SmtpClient client = new SmtpClient(); client.Credentials = new System.Net.NetworkCredential(email.email_username, email.email_password); client.Port = email.port; client.Host = email.host; client.EnableSsl = true; try { client.Send(mail); //Page.RegisterStartupScript("UserMsg", "<script>alert('Successfully Send...');if(alert){ window.location='SendMail.aspx';}</script>"); } catch (Exception ex) { Exception ex2 = ex; string errorMessage = string.Empty; while (ex2 != null) { errorMessage += ex2.ToString(); ex2 = ex2.InnerException; } //Page.RegisterStartupScript("UserMsg", "<script>alert('Sending Failed...');if(alert){ window.location='SendMail.aspx';}</script>"); } } return(Ok()); }