0 Replies - 4223 Views - Last Post: 26 September 2012 - 03:52 AM

#1 Dipz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 22-February 11

How To Pass Values Of Controller Action Method to Custom Membership

Posted 26 September 2012 - 03:52 AM

Hi,

I have a problem, and still can't solve this. I want to pass a value from Register actionmethod (@AccountController) to MyMembershipProvider class. I use property to do this, but the property result in MyMembershipProvider always contains null.


bellow my Register method

     public class AccountController : Controller
    { 
	    [HttpPost]
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
		     //Instance the class and passing value to LastName property in MyMembership class
                MyMembershipProvider myMembership = new MyMembershipProvider();
                myMembership.LastName = model.LastName;

                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);
            }

            return View(model);
        }
	}



and my MyMembershipProvider class (custom membership provider class)

    	public class MyMembershipProvider : MembershipProvider
	{
		public string LastName { get; set;} // but the property value always contain null
	
		public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, 
        bool isApproved, object providerUserKey, out MembershipCreateStatus status)
		{
			return this.CreateUser(username, password, email, passwordQuestion, passwordAnswer, isApproved, providerUserKey, LastName, out status);
		}
		
		public AddParameterMembership CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, string LastName, out MembershipCreateStatus status)
		{
		
		}

	}


how can i solve the problem?
thanks :)

Is This A Good Question/Topic? 0
  • +

Page 1 of 1