/// <summary> /// Error handling. /// </summary> protected override void OnError(EventArgs e) { base.OnError(e); // Delete the saved state SavedFormState state = FormStateHelper.GetSavedState(); if (state != null) { state.Delete(); } // Redirect to the same page Response.Redirect(URLRewriter.RawUrl); }
protected void Page_Load(object sender, EventArgs e) { titleElem.TitleText = GetString("RestorePostback.Header"); titleElem.TitleImage = GetImageUrl("Others/Messages/info.png"); lblInfo.Text = GetString("RestorePostback.Info"); okText = GetString("General.OK"); cancelText = GetString("General.Cancel"); // Add the state fields SavedFormState state = FormStateHelper.GetSavedState(); if (state != null) { // Render the hidden fields for the form items NameValueCollection form = state.Form; foreach (string name in form.Keys) { ltlValues.Text += "<input type=\"hidden\" name=\"" + name + "\" value=\"" + HttpUtility.HtmlEncode(form[name]) + "\" />\n"; } state.Delete(); } else { lblInfo.Text = GetString("RestorePostback.InfoNotSaved"); if (Request.RawUrl.IndexOfCSafe("/RestorePostback.aspx", true) < 0) { mBodyParams = "onload=\"document.location.replace(document.location.href); return false;\""; } plcOK.Visible = false; cancelText = GetString("General.OK"); } }
void Login1_LoggedIn(object sender, EventArgs e) { // Ensure response cookie CookieHelper.EnsureResponseCookie(FormsAuthentication.FormsCookieName); // Set cookie expiration if (Login1.RememberMeSet) { CookieHelper.ChangeCookieExpiration(FormsAuthentication.FormsCookieName, DateTime.Now.AddYears(1), false); } else { // Extend the expiration of the authentication cookie if required if (!UserInfoProvider.UseSessionCookies && (HttpContext.Current != null) && (HttpContext.Current.Session != null)) { CookieHelper.ChangeCookieExpiration(FormsAuthentication.FormsCookieName, DateTime.Now.AddMinutes(Session.Timeout), false); } } // Current username string userName = Login1.UserName; // Get info on the authenticated user UserInfo ui = UserInfoProvider.GetUserInfo(userName); // Check whether safe user name is required and if so get safe username if (RequestHelper.IsMixedAuthentication() && UserInfoProvider.UseSafeUserName && (ui == null)) { userName = ValidationHelper.GetSafeUserName(this.Login1.UserName, CMSContext.CurrentSiteName); CMSContext.AuthenticateUser(userName, this.Login1.RememberMeSet); } // Set culture DropDownList drpCulture = (DropDownList)Login1.FindControl("drpCulture"); if (drpCulture != null) { string selectedCulture = drpCulture.SelectedValue; // Not the default culture if (selectedCulture != "") { // Update the user ui.PreferredUICultureCode = selectedCulture; UserInfoProvider.SetUserInfo(ui); // Update current user CMSContext.CurrentUser.PreferredUICultureCode = selectedCulture; } } // Splash screen handling bool splashScreenEnabled = false; LicenseKeyInfo lki = LicenseKeyInfoProvider.GetLicenseKeyInfo(URLHelper.GetCurrentDomain()); if ((lki != null) && lki.IsTrial && ui.UserSettings.UserShowSplashScreen) { if (lki.ExpirationDate != DateTimeHelper.ZERO_TIME) { // Display splash screen only if using trial license splashScreenEnabled = true; } } // Splash screen string returnUrl = ReturnUrl; // Return url is not specified or is relative path or hash is valid if (string.IsNullOrEmpty(returnUrl) || returnUrl.StartsWith("~") || returnUrl.StartsWith("/") || QueryHelper.ValidateHash("hash")) { if (splashScreenEnabled && ui.UserSettings.UserShowSplashScreen && SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSShowSplashScreen")) { if ((!String.IsNullOrEmpty(CMSContext.CurrentSiteName)) && (returnUrl.Contains("cmsdesk") || IsSiteManager)) { URLHelper.Redirect(ResolveUrl("~/CMSSiteManager/SplashScreen.aspx?continueurl=" + returnUrl)); } } // Destination page URL if (returnUrl.Contains("restorepost")) { // Delete the saved state SavedFormState state = FormStateHelper.GetSavedState(); if (state != null) { state.Delete(); } returnUrl = URLHelper.RemoveParameterFromUrl(returnUrl, "restorepost"); URLHelper.Redirect(ResolveUrl(returnUrl)); } } else { URLHelper.Redirect(ResolveUrl("~/CMSMessages/Error.aspx?title=" + ResHelper.GetString("general.badhashtitle") + "&text=" + ResHelper.GetString("general.badhashtext"))); } }