I am hoping for fruitful answer to this. How should i move the settings provided in web.config for asp.net membership into a database for cross application customization. For example membership information include below
<providers>
<add
name="OdbcProvider"
type="Samples.AspNet.Membership.OdbcMembershipProvider"
connectionStringName="OdbcServices"
enablePasswordRetrieval="true"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
writeExceptionsToEventLog="true" />
</providers>
</membership>
.NET 2.0
ASP.NET 2.0
moving asp.net membership specific settings to a separate config file
Yes, you can! We have done this successfully.
You can do it in a few ways, one is to inject whichever properties you need into an instance of the provider (this example assumes you are using SqlMembershipProvider
and shows how you can inject the connection string, but you can take a look at the source of OdbcMembershipProvider
to get an idea where to do this yourself):
public static void InjectConnectionStringIntoSqlMembershipProvider(SqlMembershipProvider provider, string connectionString) {
Type t = typeof(SqlMembershipProvider);
FieldInfo fi = t.GetField("_sqlConnectionString", BindingFlags.NonPublic | BindingFlags.Instance);
if (fi == null) throw new InvalidOperationException("Invalid private identifier.");
fi.SetValue(provider, connectionString);
}
Or, you can create your own provider by creating a class that inherits MembershipProvider
.
Or, as the link from @Andomar suggests, you can inherit from any implementation of MembershipProvider
(such as SqlMembershipProvider
, amongst others), to get what you want.
We have done all three over the years depending on how much customisation was required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With