How does Membership.ValidateUser method access a database?
12,890
It' used the MembershipProvider
specified on your Web.config file to validate the user. By default, it uses DefaultMembershipProvider
Author by
user2923864
Updated on June 04, 2022Comments
-
user2923864 almost 2 years
I wanted to build a membership system at the beginning of my MVC project and I used Membership.ValidateUser method to verify credentials. However I could not understand how does this method access my database and check my email and password informations.
[HttpPost] [ActionName("Login")] public ActionResult Login(LoginModel loginModel) { if (Membership.ValidateUser(loginModel.Email, loginModel.Password)) { FormsAuthentication.SetAuthCookie(loginModel.Email, true); return Json(true); } return new JsonNetResult() { Data = new { Error = true, Messages = new[] { new { Message = "Wrong username or password" } } } }; }
-
user2923864 over 9 years<add name="MyMembershipProvider" type="MyProject.Domain.Administration.Domain.Membership.MyMembershipProvider" connectionStringName="MembershipDb" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" maxInvalidPasswordAttempts="99" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /> how does it get which database or table i use to hold my credentials
-
Paul Zahra over 9 yearsYour data store is defined in your connection string which is referenced in the code in your comment by connectionStringName="MembershipDb" so it uses the DB in your connection string you've defined in your web.config named MembershipDb