I had added in a new column called “ForgotPasswordDate” into aspnet_Membership table. When a user hit the submit button in the Password Recovery Control, it would store the timing that user hit the button into the “ForgotPasswordDate” column by using the getDate() method.
After which, user would receive an email which contain an URL directing them into ChangePassword.apsx.
I wanted to make the ChangePassword.aspx page expired after 1 day the user had requested for new password. This would be done by using the time in “ForgotPasswordDate” column and using the AddDay() method.
However, the code gave me a problem. Which I think they could not recognize the “ForgotPasswordDate” column inside the Membership table.
This is the code which had an error:
if (DateTime.Now < user.ForgotPasswordDate.AddMinutes(3))
for testing purposes, currently I just set the logic as 3 minutes.
And the error message is:
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?
Here is the whole code:
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");
}
}
}
is there anyway that the system could recognize the new column in aspnet_membership table?
I would find out which stored procedure the membership uses, modify and include the new columns. Then you may have to override the current membership class to include the new properties.