protected void ButtonSignin_Click(object sender, EventArgs e) { try { bool success; FeedbackContainerControl.ClearValidationErrors( TextBoxUserName, TextBoxPassword); SignInFeedback.ValidateRequired(TextBoxUserName, "Username", out success); SignInFeedback.ValidateRequired(TextBoxPassword, "Password", out success); if (SignInFeedback.ValidationErrorCount != 0) { return; } var usernameEntered = TextBoxUserName.Text.Trim(); var passwordEntered = TextBoxPassword.Text.Trim(); HandleSignin(usernameEntered, passwordEntered); } catch (VoteException ex) { SignInFeedback.AddError(ex.Message); } catch (Exception ex) { SignInFeedback.AddError("Your signin failed due to an unexpected error."); SignInFeedback.HandleException(ex); } }
private void Page_Load(object sender, EventArgs e) { Master.SetJavascriptNotNeeded(); if (!IsPostBack) { try { if (GetQueryString("signout") .IsEqIgnoreCase("Y")) { FormsAuthentication.SignOut(); // Get rid of menus InitializeSessionVariables(); Response.Redirect(FormsAuthentication.LoginUrl); } if (HttpContext.Current.User.Identity.IsAuthenticated && !string.IsNullOrWhiteSpace(UserSecurityClass)) { Response.Redirect(FormsAuthentication.GetRedirectUrl(HttpContext.Current.User.Identity.Name, true)); } Page.Title = "Sign In"; Page.IncludeCss("/css/vote/SignIn.css", "if IE 7", "ie7"); if (Request.QueryString["Timeout"] == "Y") { InfoMessage1.InnerText = "You were signed out due to inactivity. Please sign in again. "; InfoMessage1.AddCssClasses("warn"); } else if (Request.QueryString["Security"] == "Y") { InfoMessage1.InnerText = "Your sign in does not allow access to the page you requested."; InfoMessage1.AddCssClasses("error"); InfoMessage2.InnerText = "If you have different credentials you can use them to sign in again."; } Session.Timeout = 60; var autoLoginUserName = Session["AutoLoginUserName"] as string; if (!string.IsNullOrEmpty(autoLoginUserName)) { //Session.Remove("AutoLoginUserName"); try { HandleSignin(autoLoginUserName, null); } catch {} // if it doesn't redirect, fall thru } } catch (Exception ex) { SignInFeedback.AddError("Your signin failed due to an unexpected error."); SignInFeedback.HandleException(ex); } } }