public ActionResult Register(UserViewModel model) { if (ModelState.IsValid) { var passwordSalt = CryptoService.GenerateSalt(); byte[] bytePassword = Encoding.UTF8.GetBytes(model.UserPassword); var hmac = CryptoService.ComputeHMAC256(bytePassword, passwordSalt); var verificationCode = Guid.NewGuid().ToString(); var user = new User() { UserId = Guid.NewGuid(), UserName = model.UserName, Email = model.UserEmail, FirstName = model.FirstName, LastName = model.LastName, PasswordSalt = Convert.ToBase64String(passwordSalt), UserPassword = Convert.ToBase64String(hmac), VerificationCode = verificationCode, }; dbContext.Users.Add(user); dbContext.SaveChanges(); var activationUrl = "/Account/ActivateAccount?VerificationCode=" + verificationCode; var activationLink = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, activationUrl); RegisterEmailHelper.SendVerificationLink(model.UserEmail, activationLink); return(View()); } return(View()); }