public ActionResult ResetPassword() { var context = new SitecoreContext(); var model = context.GetCurrentItem <ResetPassword>(); if (Request.QueryString["email"] == null || Request.QueryString["resetid"] == null) { WebUtil.Redirect("/Home"); } model.email = Request.QueryString["email"]; model.resetid = FormatUtils.ConvertToGuid(Request.QueryString["resetid"]); SitecoreProfileService scProfileService = new SitecoreProfileService(); var scUserName = scProfileService.GetUserByEmail(model.email); ProfileService profileService = new ProfileService(); var user = scProfileService.GetUser(scUserName); if (Session["ResetPasswordError"] != null) { List <ModelErrorCollection> allerror = (List <ModelErrorCollection>)Session["ResetPasswordError"]; foreach (var item in allerror) { foreach (var subItem in item) { ModelState.AddModelError("", subItem.ErrorMessage.ToString()); } } Session["ResetPasswordError"] = null; } if (user != null && user.Profile != null) { Guid userResetId = FormatUtils.ConvertToGuid(user.Profile.GetCustomProperty("Forgot Password Unique Id")); var forgotPasswordTimestamp = user.Profile.GetCustomProperty("Forgot Password Timestamp"); if (Guid.Equals(userResetId, model.resetid)) { DateTime expireDate = DateUtil.ParseDateTime(forgotPasswordTimestamp, DateTime.MinValue); if (expireDate != DateTime.MinValue) { int forgotPasswordExpirationTime = Int32.Parse(Sitecore.Configuration.Settings.GetSetting("ForgotPasswordExpirationTime")); if (DateTime.Now > expireDate.AddHours(forgotPasswordExpirationTime)) { model.hideUIElement = true; ViewData["message"] = model.MessageLinkExpired; // WebUtil.Redirect("/Home"); } } } else { model.hideUIElement = true; ViewData["message"] = model.MessageLinkInvalid; //WebUtil.Redirect("/Home"); } } return(View(model)); }