protected void Login1_LoggingIn(object sender, LoginCancelEventArgs e) { if (someCondition) { e.Cancel = true; } }
protected void Login1_LoggedIn(object sender, EventArgs e) { if (someCondition) { FormsAuthentication.GetAuthCookie(Login1.UserName, false).Expires = DateTime.Now.AddDays(1); } else { FormsAuthentication.RedirectFromLoginPage(Login1.UserName, false); } }In this example, the LoggedIn event of the Login control is handled. Depending on a certain condition, either a custom authentication cookie is set by accessing the FormsAuthentication.GetAuthCookie method, or the user is redirected to the originally requested page by calling FormsAuthentication.RedirectFromLoginPage. The package library for System.Web.UI.WebControls is the .NET Framework Class Library.