Twitter Feed Popout byInfofru

Configuration Membership API 2.0

Membership API is yet another enhancement from team. In this post, I will guide you through the configuring of Membership API to the enhanced usage.

So, to get started let me clear one more confusion which most of people have in there mind

They think that Membership API does not use any database behind and runtime engine perform some miracle at the back end  and all the user information is stored somewhere which is known by runtime engine.


That is wrong ..... big WRONG ....

By default, uses SQL Server as the back end of Membership API. If you have planned to use it, before doing any thing you need to implement the schema of Membership API to your database.

Step 1 (Implement Schema & Configure Database):

To do that, you need to use aspnet_regsql. which can be accessed by the instruction give below.

  • Go to X:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727 (version of dotnet framework can be vary but it should be at least 2.0)
  • Find and execute aspnet_regsql which will appear following screen.


  • Once you click next, you will be asked to "Configure SQL Server for application services" or "Remove application services information from existing database". You need to select the first one.
  • Select the appropriate database, click next and you are done with the database stuff.

Step 2 (Configure Application):

In this step we will configure our existing or new application to user membership API.

Please bear in mind that Web Application Administration is a very handy and useful tool to check Membership API integration.

Now, to use API you need to specify the connection string of the database which we have configured with aspnet_regsql.

  • Add the following connection string in web.config
   1: <add name="ConnectionString" connectionString="Data Source=SAMHEAVEN;Initial Catalog=Northwind;User Id=sa;Password=usam;"
   2:      providerName="System.Data.SqlClient" />
  • Specify membership and role configuration under system.web of web.config.
   1: <roleManager enabled="true">
   2:    <providers>
   3:      <clear/>
   4:      <add name="AspnetSqlRoleProvider" applicationName="/AppName" connectionStringName="ConnectionString" type="System.Web.Security.SqlRoleProvider"/>
   5:    </providers>
   6:  </roleManager>
   7:  <membership>
   8:    <providers>
   9:      <clear/>
  10:      <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ConnectionString" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/DanyTech" requiresUniqueEmail="true" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
  11:    </providers>
  12:  </membership>


  • Finally, you need to set authentication type.
   1: <authentication mode="Forms" />

To be descriptive, we have specified settings for two basic parts of Membership API. which is using Connection String called "connectionString" which we have created in the first step.

AspNetSqlMembershipProvider and  AspnetSqlRoleProvider have an attribute called applicationName which is really important. All the information of the Membership API will stored in the database against the applicationName specified here.

Where as, AspNetSqlMembershipProvider have a list of settings. Click here to get the complete list of Membership Provider settings.

Now the configuration stuff is complete. You can check is every thing running fine by clicking on the Configuration Icon give right above the solution explorer.


Go to the security tab and check you can create some users and roles (at least administrator, user) . If not then make sure you have not skipped any step.