I'm checking whether the last time a user has changed the password. If it's more than 90 days, I'll redirect the user to the Password Change page.
protected void LoginUser_LoggedIn(object sender, EventArgs e)
{
//has their password expired?
var _user = MembershipRepository.GetUser(this.LoginUser.UserName);
if (_user != null
&& _user.LastPasswordChangedDate.Date.AddDays(90) < DateTime.Now.Date)
{
Server.Transfer("~/SiteNav/ChangePassword.aspx");
}
}
The problem I'm having is that when ChangePassword.aspx displays, the user is not logged in. Unless I refresh manually the page, then the LoginStatus control shows the username of the user.
I've tried to refresh the page in the code, but it's still not working.
protected void Page_Load(object sender, System.EventArgs e)
{
var _url = HttpContext.Current.Request.Url.ToString();
if (_url.ToLower().EndsWith("default.aspx"))
{
Page.ClientScript.RegisterStartupScript(this.GetType(),
"RefreshPage", "window.location.reload();", true);
Response.Redirect("~/SiteNav/ChangePassword.aspx");
}
}
It's so confusing. When we get to the LoggedIn event, I though the user was already logged in.
Thanks for helping.