ASP.NET Website Development - Membership and Role Management

Membership and role management

I. Membership Introduction

ASP.NET membership supports the following features:

(1) Create a new user and password.

(2) Store membership information (username, password and supporting data) in Mixrosoft SQL ActiveDirectory or other data store.

(3) Authenticate users who visit the site. Users can be authenticated programmatically, or you can use the ASP.NET login control to create a complete authentication system with little or no code.

(4) Manage passwords, including creating, changing and resetting passwords. Depending on the membership option selected by the user, the membership system may also provide an automatic password reset system using user-supplied questions and answers.

(5) Expose the authenticated user's unique ID, which can be used by users in their own applications or integrated with the ASP.NET personalization and role management (authorization) system.

(6) Specify a custom membership provider, which allows users to instead manage membership with their own code and maintain membership data in a custom data store.

二、Membership



Properties of the Membership class

Methods of the Membership class

3. Establish Membership Support

1. Create a new ASPNETDB database, enter aspnet_regsql at the Visual Studio2008 command prompt, and then follow the prompts to create an ASPNETDB database.

2. Create a new ASP.NET website and modify the code as follows:



Then open the "Web Site" in the project, open "ASP.NET Configuration" and proceed to the next step according to the prompts.

Examples are as follows:


4. Role management

A role refers to a class of users or groups of users with the same permissions rather than a single user. There is a close relationship between roles and authorization. The role management provided by ASP.NET divides the entire control process into two steps:

(1) Access rights are associated with roles

(2) Roles are associated with users

The following is the member role management model


Five, Roles class

The Roles class separates the user interface from the role management provider that performs underlying data access, thereby providing technical support for quickly implementing role management applications that store multiple data sources.

In ASP.NET applications, the Roles class is primarily used to manage user membership in roles in order to implement authorization checks. The Roles class has the following main functions:

(1) Create and manage roles.

(2) Store role information in SQL Server or other data sources.

(3) Get details about role management configuration

The main attributes of the role class Roles:


The main method of the role class Roles:


Start member role


Role management example:


6. Login control

The Login control is a composite control that provides a common user interface for a login form


There are other controls





Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325909748&siteId=291194637