Introduction
We create a website or web application that has a login page, user panel, admin panel etcetera. We do a lot of code, queries to register a user and to validate a user for login in his/her panel. To reduce code or almost remove code for login/register from the application/website, the membership feature comes in ASP.NET. The membership feature provides an abstraction for the underlying data store used to maintain user credentials such as user names and passwords, and it provides an API that allows you to easily validate user credentials and manage the user database. ASP.NET supports SQL Server and Active Directory providers, and we can also create our own providers for custom stores.
This article explains:
- How to create database using SQL Server Management Studio
- How to install an ASP.NET Membership Services Database in SQL Server
Installing ASP.NET Membership Services database in SQL Server 2008
We will go through step-by-step how to create a database in SQL Server 2008 using SQL Server Management Studio then install ASP.NET membership services. So let's see that now.
- Right-click on the "Database" folder then click on "New Database".
- Open a new Database window. Click on "General" then provide a Database name then click on "OK".
- Now we will see our EmployeeDB database successfully created.
Installing ASP.NET Memberships Services Database in EmployeeDB Database
Before going to install ASP.Net membership, we need to know about aspnet_regsql.exe. The ASP.NET SQL Server Registration Tool (aspnet_regsql.exe) creates a Microsoft SQL Server database for use by the SQL Server providers, roles, profiles in ASP.NET, or to add or remove options from an existing database. We can run Aspnet_regsql.exe without any command-line arguments to run a wizard that will be explained in this article. We are installing or removing the database elements for the membership, role management, profile, Web Parts personalization, and health monitoring features using a wizard but are't covering the settings for session state and SQL cache dependency by the wizard. We can also run Aspnet_regsql.exe as a command-line tool to specify database elements for individual features to add or remove, using the options.
- Go to "C:\Windows\Microsoft.NET\Framework64\v4.0.30319" and click on aspnet_regsql.exe.
- The ASP.NET Server Setup Wizards starts; then click on the "Next" button.
- Check the radio button for "Configure SQL Server for application services" and click "Next".
- Use "SQL Authentication" and insert credentials for SQL Authentication and select the database to install ASP.Net services then click on the "Next" button.
- Check to confirm the settings; if the settings are OK then click on "Next" elsewhere click on "Previous".
- The database has been modified, click on "Finish".
- Go to SQL Server Management Studio and expand the EmployeeDB database then check the ASP.Net membership tables and views by expending the "Tables and Views" folder in the EmployeeDB database.
In the same manner we can look at the Stored Procedures by expanding the storedprocedure folder. So using this process we can enusre that the ASP.Net membership tables, views and Stored Procedures are created and our database is ready to use ASP.Net membership API.
In the next article, learn about Membership Services in Part 2. I will cover the following points:
- How to test this with application.
- How to create users.
- How to implement form authentication using membership.