In my ASP.NET Web Forms app, I'm trying to create my own SQLMembershipProvider class, to override the ConnectionString at runtime. But I am getting a configuration error: "The type 'ExtendRegv1.MyMembershipProvider' is ambiguous"
I have created the following class in the App_code folder...
My Custom Membership Provider Class
namespace ExtendRegv1
{
public class MyMembershipProvider :SqlMembershipProvider
{
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
base.Initialize(name, config);
string connectionString = "Data Source=BSHEEHAN-PC\\SQLEXPRESS;Initial Catalog=ExReg_Default;Integrated Security=True";
FieldInfo connectionStringField = GetType().BaseType.GetField("_sqlConnectionString", BindingFlags.Instance | BindingFlags.NonPublic);
connectionStringField.SetValue(this, connectionString);
}
}
}
Web config:
<membership>
<providers>
<clear />
<add name="MyMembershipProvider" type="ExtendRegv1.MyMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" maxInvalidPasswordAttempts="3" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
Thanks, Ben
public partial class MyMembershipProvider
– benni_mac_b