Setup ASP.net Membership Database And Add Accounts - Quick Start
- Posted by admin
- 18 January 2010
- Blog
Every Step You Take...
Here's one of those things I do just infrequently enough to forget a step. Now I just need to remember that I've put all the steps here.
- Provision a database. It does not need to be new, but it cannot already have the ASP.net membership provider tables in it. If it does, skip ahead to step 3.
- Use the aspnet_regsql.exe tool to create the necessary tables and stored procedures in the database. The tool can be found at <system drive letter>:\Windows\Microsoft.NET\Framework\v2.0.50727. The tool has a GUI wizard that will lead you through the steps.
- Create a web site. A local web site works fine.
-
Add the connection string to your database to the web.config file. Connection strings are placed just inside the configuration root:
<configuration>
<connectionStrings>
<add name="SqlMembershipConnection"
connectionString="Data Source=IPADDRESS;Initial Catalog=DBNAMEHERE;User
ID=DBUSERNAMEHERE;Password=PASSWORDHERE" />
</connectionStrings>
<configuration> -
Add the SqlMembershipProvider to the web.config file under the system.web node:
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="SqlMembershipConnection"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="true"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""
applicationName="NAMEOFAPPHERE"/>
</providers>
</membership>NOTE: The connectionStringName parameter of the membership provider must match the name you chose for the connection string above. The applicationName parameter allows you to use the same database for different web applications. Choose a suitable name and set the other parameters as needed.
- Add a CreateUserWizard control to the default.aspx page of your web site.
- Right click on the default.aspx page and choose "View In Browser" from the context menu.
- You know the rest...
