Is there a way to call the custom MembershipProvider I have implemented in code without having to cast the Membership class to my custom provider every time? For example, I setup my web.config like so:
<connectionStrings>
<add name="TestDB"
connectionString="conn_str_here"
providerName="System.Data.SqlClient" />
</connectionStrings>
<membership defaultProvider="CustomSqlMembershipProvider">
<providers>
<clear/>
<add name="CustomSqlMembershipProvider" type="Common.CustomSqlMembershipProvider" connectionStringName="TestDB"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
And my custom provider class:
namespace Common
{
public class CustomSqlMembershipProvider : SqlMembershipProvider
{
public void ChangeUsername()
{
// ...
}
}
}
Now to call my new custom function, is there some way to allow Membership.ChangeUsername()
versus having to do this:
CustomSqlMembershipProvider customMembership = Membership.Provider as CustomSqlMembershipProvider;
customMembership.ChangeUsername();
Doing the cast everywhere you want to use it starts to get annoying after a while. Thanks in advance.