BetterMembership


Better implementation of ExtendedMembershipProvider with compatibility for MembershipProvider

Usage

quick start

The following guide shows how to get up and running with BetterMembership.Net as quicky as possible.

Installation

The library can be installed via Nuget as follows:

PM> Install-Package BetterMembership.Net

Configuration

The providers are configured within the web.config in the usual way. Note BetterRoleProvider and BetterProfileProvider require a membershipProviderName attribute. This is used to reference an instance of the BetterMembershipProvider instance from which they will inherit the relevant settings, such as connection string and schema configuration.

<membership defaultProvider="BetterProvider">
  <providers>
    <add name="BetterProvider" type="BetterMembership.Web.BetterMembershipProvider, BetterMembership, Version=1.0.1.0, Culture=neutral, PublicKeyToken=737bc70442f2c4af" connectionStringName="DefaultConnection" autoInitialize="true" />
  </providers>
</membership>
<roleManager defaultProvider="BetterProvider" enabled="true">
  <providers>
    <add name="BetterProvider" type="BetterMembership.Web.BetterRoleProvider, BetterMembership, Version=1.0.1.0, Culture=neutral, PublicKeyToken=737bc70442f2c4af" membershipProviderName="BetterProvider" />
  </providers>
</roleManager>
<profile defaultProvider="BetterProvider" enabled="true">
  <providers>
    <add name="BetterProvider" type="BetterMembership.Web.BetterProfileProvider, BetterMembership, Version=1.0.1.0, Culture=neutral, PublicKeyToken=737bc70442f2c4af" membershipProviderName="BetterProvider" />
  </providers>
  <properties>
  </properties>
</profile>

Initialization

The providers can be initialized in one of 2 ways. Either automatically by setting the autoInitialize attribute to true, or alternatively by a call to WebSecurity.InitializeDatabaseConnection once on application startup. Support for non-default providers is only possible when using autoInitialize=true.

Regardless of how the provider is initialized, the provider must be configured via the web.config with the correct userIdColumn, userNameColumn, and userTableName attributes. When using WebSecurity.InitializeDatabaseConnection for initialization, these values must correspond to the values passed to the API call.