Can anybody please help me how to build a Monthly membership were a user registers for a month and after a month his user account gets disabled...
Thanks in advance.
Thanks
With Regards
Abhishek Rajiv Luv
"Helpful then please Mark as Answer"
http://www.codeabstract.com/
http://pluralsight.com/training/users/abhishekluv
Abhishek Luv
Participant
1802 Points
481 Posts
Monthly Membership Site using Starter Site
Nov 22, 2012 06:06 AM|LINK
Hi,
Can anybody please help me how to build a Monthly membership were a user registers for a month and after a month his user account gets disabled...
Thanks in advance.
With Regards
Abhishek Rajiv Luv
"Helpful then please Mark as Answer"
http://www.codeabstract.com/
http://pluralsight.com/training/users/abhishekluv
Basquiat
Contributor
2604 Points
743 Posts
Re: Monthly Membership Site using Starter Site
Nov 22, 2012 07:02 AM|LINK
Hi
You can do that by not specifying a DestinationPageUrl for your login control.
The do something like this for your OnLoggedIn Event.
protected void onLoggedIn(object sender, EventArgs e) { MembershipUser usrInfo = Membership.GetUser(LoginUser.UserName); if (usrInfo != null) { DateTime userCreatedDate = usrInfo.CreationDate.ToUniversalTime(); if (userCreatedDate < DateTime.Today.AddMonths(1)) { Response.Redirect("~/welcome.aspx"); } else { Response.Redirect("~/membershipexpired.aspx"); } } }Basquiat
Contributor
2604 Points
743 Posts
Re: Monthly Membership Site using Starter Site
Nov 22, 2012 07:24 AM|LINK
Sorry....that should be the OnLoggingIn event and you'd want to change the account to not-approved...and I had the date formule wrong
protected void OnLoggingIn(object sender, EventArgs e) { MembershipUser user = Membership.GetUser(LoginUser.UserName); if (user != null) { DateTime userCreatedDate = user.CreationDate.ToUniversalTime(); if (userCreatedDate.AddMonths(1) < DateTime.Today) { user.IsApproved = false; Membership.UpdateUser(user); Response.Redirect("~/membershipexpired.aspx"); } else { Response.Redirect("~/welcome.aspx"); } }