Is there a way to change the ValidateUser method in MVC 3?
For example.. require an additional parameter like an identification number or something like that?
I get the feeling this stuff is quite static…
Oh and is there a way to use another database than the existing mdf+ldf SQL database (for example a MySQL DB)?
Edit:
I’m still having trouble with setting this stuff up.
In my BOMembershipProvider class I have
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
namespace MVCTests
{
public class BOMembershipProvider : MembershipProvider
{
public override string ApplicationName
and so on.
It’s located in my App_Data folder.
My Web.config looks like this:
<membership defaultProvider="BOMembershipProvider">
<providers>
<clear/>
<add name="BOMembershipProvider" type="BOMembershipProvider"
connectionStringName="ApplicationServices"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
applicationName="/" />
</providers>
It’s still giving me the error with the type not found thing. Any hints, solutions, …?
Oh and I tried that with MVCTests.BOMembershipProvider in the Web.config too, with no results 🙁
You can write a custom Membership provider to change the behavior of ValidateUser. This will also enable you to use a different database provider.
See http://msdn.microsoft.com/en-us/library/aa479048.aspx or google asp.net custom membership provider.
This example of a custom membership provider that uses entity framework codefirst helped me to get started:
http://codefirstmembership.codeplex.com/