What about on this page?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using System.IO;
using System.Web.Security;
namespace OmegaLove.Web.UI
{
public partial class ctrlLogin : OmegaLoveBasePageUserControl
{
protected MembershipUser loginUser;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Search recursively for a Login control, called LoginStatus
// starting from within the Page object.
Login curLogin = FindControl<Login>(this, "LoginStatus");
// You still should check whether you got something back!
if (curLogin != null)
Page.SetFocus(curLogin.FindControl("UserName"));
}
}
// Search recursively a control sub-tree for a specific control.
// It searches every control in the sub-tree, so it potentially
// could be optimized to search only, say, INamingContainers.
public T FindControl<T>(string id) where T : Control
{
return FindControl<T>(Page, id);
}
public static T FindControl<T>(Control startingControl, string id) where T : Control
{
T found = null;
foreach (Control activeControl in startingControl.Controls)
{
found = activeControl as T;
if (found == null)
{
found = FindControl<T>(activeControl, id);
}
else if (string.Compare(id, found.ID, true) != 0)
{
found = null;
}
if (found != null)
{
break;
}
}
return found;
}
protected void btnLogout_Click(object sender, EventArgs e)
{
MembershipUser mu = Membership.GetUser();
mu.Comment = String.Empty;
Membership.UpdateUser(mu);
FormsAuthentication.SignOut();
}
protected void LoginStatus_LoggedIn(object sender, EventArgs e)
{
if (loginUser == null)
{
var lgnMain = ((Login)LoginView1.FindControl("LoginStatus"));
string username = lgnMain.UserName;
loginUser = Membership.GetUser(username);
}
// represents the active login session
Guid g = Guid.NewGuid();
HttpCookie c = Response.Cookies[FormsAuthentication.FormsCookieName];
FormsAuthenticationTicket ft = FormsAuthentication.Decrypt(c.Value);
//Generate a new ticket that includes the login session ID
var ftNew = new FormsAuthenticationTicket(
ft.Version,
ft.Name,
ft.IssueDate,
ft.Expiration,
ft.IsPersistent,
g.ToString(),
ft.CookiePath);
////Store the expiration date and login session ID in Membership
//loginUser.Comment = "LoginExpiration;" + ft.Expiration + "|LoginSessionID;" + g;
//Membership.UpdateUser(loginUser);
////Re-issue the updated forms authentication ticket
//Response.Cookies.Remove(FormsAuthentication.FormsCookieName);
////Basically clone the original cookie except for the payload
//var newAuthCookie = new HttpCookie(
// FormsAuthentication.FormsCookieName,
// FormsAuthentication.Encrypt(ftNew));
////Re-use the cookie settings from forms authentication
//newAuthCookie.HttpOnly = c.HttpOnly;
//newAuthCookie.Path = c.Path;
//newAuthCookie.Secure = c.Secure;
//newAuthCookie.Domain = c.Domain;
//newAuthCookie.Expires = c.Expires;
////And set it back in the response
//Response.Cookies.Add(newAuthCookie);
}
protected void LoginStatus_LoggingIn(object sender, LoginCancelEventArgs e)
{
//if (loginUser == null)
//{
// var lgnMain = ((Login)LoginView1.FindControl("LoginStatus"));
// string username = lgnMain.UserName;
// loginUser = Membership.GetUser(username);
//}
//Only need to check if the user instance already has login information
//stored in the Comment field.
//if ((!Equals(loginUser, null)))
// if ((!String.IsNullOrEmpty(loginUser.Comment)) && loginUser.Comment.Contains("LoginExpiration"))
// {
// string currentExpirationString = loginUser.Comment.Split("|".ToCharArray())[0];
// DateTime currentExpiration = DateTime.Parse((currentExpirationString.Split(";".ToCharArray()))[1]);
// //The user was logged in at some point previously and the login is still
// //valid
// if (DateTime.Now <= currentExpiration)
// {
// e.Cancel = true;
// var tx = (Literal) LoginView1.FindControl("FailureText");
// ScriptManager.RegisterStartupScript(Page, GetType(), "message",
// "alert('You are already logged in. You are being logged out!');",
// true);
// }
// }
}
}
}
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156:





by: mwvisa1Posted on 2009-11-05 at 15:35:43ID: 25755301
protected void btnLogout_Click(object sender, EventArgs e)
{
MembershipUser mu = Membership.GetUser();
mu.Comment = String.Empty;
Membership.UpdateUser(mu);
FormsAuthentication.SignOu
'FormsAuthentication.Redir
}
Remove the bolded line above.