public ActionResult ConfirmEmail(string userID, string code)
 {
     var userStore = new UserStore<IdentityUser>();
     UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
     var user = manager.FindById(userID);
     CreateTokenProvider(manager, EMAIL_CONFIRMATION);
     try
     {
         IdentityResult result = manager.ConfirmEmail(userID, code);
         if (result.Succeeded)
         {
             TempData["ConfirmationResponse"] = "You have successfully registered for an account. Please verify your account by clicking on the link sent to you in your e-mail.";
             return RedirectToAction("Login");
         }
         else
         {
             TempData["ConfirmationResponseError"] = "Your validation attempt has failed. We may be experiencing system problems. Please try again later.";
             return RedirectToAction("Login");
         }
     }
     catch
     {
         TempData["ConfirmationResponseError"] = "Your validation attempt has failed. We may be experiencing system problems. Please try again later.";
         return RedirectToAction("Login");
     }
 }
 public ActionResult ConfirmEmail(string userID, string code)
 {
     var userStore = new UserStore<IdentityUser>();
     UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
     var user = manager.FindById(userID);
     CreateTokenProvider(manager, EMAIL_CONFIRMATION);
     try
     {
         IdentityResult result = manager.ConfirmEmail(userID, code);
         if (result.Succeeded)
             ViewBag.Message = "You are now registered!";
     }
     catch
     {
         ViewBag.Message = "Validation attempt failed!";
     }
     return View();
 }
        public ActionResult ConfirmEmail(string userId, string code)
        {
            var userStore = new UserStore<IdentityUser>();
            UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
            var user = manager.FindById(userId);

            CreateTokenProvider(manager, EMAIL_CONFIRMATION);
            try
            {
                IdentityResult result = manager.ConfirmEmail(userId, code);
                if (result.Succeeded)
                {
                    IAuthenticationManager authenticationManager
                                          = HttpContext.GetOwinContext().Authentication;
                    authenticationManager
                   .SignOut(DefaultAuthenticationTypes.ExternalCookie);

                    var identity = new ClaimsIdentity(new[] {
                                            new Claim(ClaimTypes.Name, user.UserName),
                                        },
                                        DefaultAuthenticationTypes.ApplicationCookie,
                                        ClaimTypes.Name, ClaimTypes.Role);

                    // SignIn() accepts ClaimsIdentity and issues logged in cookie.
                    authenticationManager.SignIn(new AuthenticationProperties
                    {
                        IsPersistent = false
                    }, identity);

                    ViewBag.UserName = user.UserName;
                    ViewBag.Message = "You are now registered!";

                }

            }
            catch
            {
                ViewBag.Message = "Validation attempt failed!";
            }
            return View();
        }