Site icon port135.com

How to use membership system in ASP.NET project?

If you want to add membership capabilities (register, log in, managing roles etc.), to your web page, follow the post below.

You must have noticed that there are “Log in” and “Register” links in the top right-hand corner in an ASP.NET web page. Even thought the pages are exist, you won’t be able to use them unless you’ve done the corresponding installation and configuration process.

I will be explaining how to install membership tables and configure it.

Steps

  1. Run aspnet_regsql.exe in .NET Framework folder

    Running aspnet_regsql.exe

  2. A wizard which is going to help us to install necessary membership tables in the database will show up. Follow the steps through the wizard. In “Select a Setup Option” window, choose “Configure SQL Server for application services“.

    Choose first option to create membership tables

  3. In “Select the Server and Database” window, make sure you’ve entered server name with instance name and selected the appropriate database from the combo list.

    Database settings

  4. After completing the wizard, one more setting will be left. Go to your “web.config” file in Visual Studio. Change the connection strings with the one you use for these tags: “membership“, “profile“, “roleManager
    <membership>
      <providers>
        <clear />
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ltesitecheckConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
      </providers>
    </membership>
    <profile>
      <providers>
        <clear />
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ltesitecheckConnectionString" applicationName="/" />
      </providers>
    </profile>
    <roleManager enabled="false">
      <providers>
        <clear />
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ltesitecheckConnectionString" applicationName="/" />
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
      </providers>
    </roleManager>
  5. You’re all set! In order to manage users, roles and rules, go to “Project > ASP.NET Configuration > Security” in Visual Studio.

    Web Site Administration Tool

Exit mobile version