当前位置: 首页>>代码示例>>C#>>正文


C# UserManager.ConfirmEmail方法代码示例

本文整理汇总了C#中UserManager.ConfirmEmail方法的典型用法代码示例。如果您正苦于以下问题:C# UserManager.ConfirmEmail方法的具体用法?C# UserManager.ConfirmEmail怎么用?C# UserManager.ConfirmEmail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserManager的用法示例。


在下文中一共展示了UserManager.ConfirmEmail方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConfirmEmail

 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");
     }
 }
开发者ID:andrewstec,项目名称:phase2_lastday,代码行数:26,代码来源:HomeController.cs

示例2: ConfirmEmail

 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();
 }
开发者ID:andrewstec,项目名称:farmsale_phase2,代码行数:18,代码来源:HomeController.cs

示例3: ConfirmEmail

        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();
        }
开发者ID:rachelyu0102,项目名称:dating-project-ssd,代码行数:41,代码来源:HomeController.cs


注:本文中的UserManager.ConfirmEmail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。