ASP.NET has a membership provider built-in that can be used to authenticate and manage the users who will be visiting your website. These features can be used to determine if a user viewing the website is authenticated or anonymous and to display content according to who is viewing the page. There are also controls for creating new users, changing passwords, and logging in.
Creating The Database
In order to use the ASP.NET membership provider you will need to create a database. The membership tables can either be part of the application’s database or it can be its own database.
Integrating the membership tables with your application’s database has a few benefits such as being able to create foreign keys between the membership tables and your own. However, creating the membership tables in their own database will allow multiple website to use the same database for authentication.
To crate the tables and store procedures navigate to Start –> All Programs –> Microsoft Visual Studio XXXX –> Visual Studio Tools –> Visual Studio Command Prompt.
Enter the command aspnet_reqsql to start the ASP.NET SQL Server Setup Wizard
After the wizard has started click next.
Select “Configure SQL Server for application services.”
Enter the server’s name and credentials if necessary. Also select the database where the ASP.NET membership tables and stored procedures should be created.
Verify the entered information is correct and click next. Then click finish.
The tables and stored procedures for ASP.NET Membership have now been added to the selected database.
Configuring The Application
The next step is to configure the application’s web.config file.
First setup your connection string to the database. If you created the ASP.NET Membership tables in a separate database you will need to create two connection strings.
Now we need to change the authentication mode to forms and set the login URL for the web site.
Next we need to setup the membership settings.
Note: The application name setting is used when multiple websites use the same database for authentication.
Moving Forward
Your database and website are now configured to use the built in ASP.NET membership provider. In part 2 I will discuss the controls(login, register, validation) built into ASP.NET to take advantage of the membership provider.