Reputation: 57469
I have created a BasicMembershipProvider class that inherits from MembershipProvider, when implemented, the ValidateUser does not get called. This is my setup:
web.config
<membership defaultProvider="BasicMembershipProvider">
<providers>
<clear/>
<add name="BasicMembershipProvider" type="MyMVCProject.Providers.BasicMembershipProvider"/>
</providers>
</membership>
BasicMembershipProvider.cs
public class BasicMembershipProvider : MembershipProvider
{
//THIS FUNCTION NEVER GETS CALLED
public override bool ValidateUser(string email, string password)
{
//Do custom checks.
}
}
Controller
FormsAuthentication.Authenticate(model.Email, model.Password)
Is this the way to go about overriding the MembershipProvider with my own membership logic? If so, why doesn't the overidden function ValidateUser
gets called whenever I call FormsAuthentication.Authenticate()
?
Upvotes: 1
Views: 1164
Reputation: 7941
AFAIK the FormsAuthentication.Authenticate
does not use Membership.Validate
method. You have to call the Membership.Validate
manually.
The Authenticate method verifies user credentials that are stored in the credentials section of the application configuration file. Alternatively, you can use ASP.NET membership to store user credentials and call the ValidateUser to verify the credentials.
Upvotes: 7