![](/img/trans.png)
[英]Is is possible to change the date format of the LastLoginDate in the aspnet_membership table?
[英]could not find new column in aspnet_Membership table
我在aspnet_Membership表中添加了一个名为“ ForgotPasswordDate”的新列。 当用户单击密码恢复控件中的“提交”按钮时,它将使用getDate()方法将用户单击按钮的时间存储在“ ForgotPasswordDate”列中。
之后,用户将收到一封包含URL的电子邮件,该URL将其定向到ChangePassword.apsx。
我想让ChangePassword.aspx页在用户请求新密码1天后过期。 这可以通过使用“ ForgotPasswordDate”列中的时间并使用AddDay()方法来完成。
但是,代码给了我一个问题。 我认为他们无法识别Membership表中的“ ForgotPasswordDate”列。
这是发生错误的代码:
if (DateTime.Now < user.ForgotPasswordDate.AddMinutes(3))
出于测试目的,目前我只设置逻辑为3分钟。
错误消息是:
System.Web.Security.MembershipUser' does not contain a definition for 'ForgotPasswordDate' and no extension method 'ForgotPasswordDate' accepting a first argument of type 'System.Web.Security.MembershipUser' could be found (are you missing a using directive or an assembly reference?
这是完整的代码:
protected void Page_Load(object sender, EventArgs e)
{
//if the id is in the query string
if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
{
//store the user id
Guid userId = new Guid(Request.QueryString["ID"]);
//attempt to get the user's information
MembershipUser user = Membership.GetUser(userId);
if (DateTime.Now < user.ForgotPasswordDate.AddMinutes(3)) //here is the part
{
//Page not expire yet.
hidden.Text = user.ProviderUserKey.ToString();
Server.Transfer("~/ChangePassword.aspx");
}
else
{
//Expired; direct to Page Expired Page
Server.Transfer("~/PageExpired.aspx");
}
}
}
无论如何,系统可以识别aspnet_membership表中的新列?
我将找出成员资格使用哪个存储过程,修改并包括新列。 然后,您可能必须覆盖当前成员资格类以包括新属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.