ASP. net2.0 Provider Model (2)

Source: Internet
Author: User

In the first part, we learned ASP. NET provider The basic concepts of the model. ASP. NET Built-in Provider The framework of the model. For details, we will discuss Membership Of Provider Model

 

Membership providerBasic Class

 
First, let's look at the following figure.



As you can see, all Provider The basic classes of the model are Providerbase . Providerbase Class resident in System. configuration. dll In System. configuration. Provider In the namespace Class is marked Abstract It can be used as a template for the successor. The An important method is Initalize () . This method is usually used from the configuration file Web. config Read configuration information and initialize Provider Model

 

MembershipproviderClass resident inSystem. Web. SecurityIn a namespace, this class is composedProviderbase classInherited and added the feature methods and attributes required by the member relationship (these methods and attributes are used to establish and manage user-specific), The class is also markedAbstract.


Finally,
Sqlmembership Class resident in System. Web. Security Namespace, which is from Membershipprovider Class. This is a specific class that can be executed from Providerbase And Membershipprovider Defined specifically for execution SQL Server Database attributes and methods.


Other
ProviderClass

Similar class inheritance relationships can be found in SQL role , SQL profile provider See in the model. For example SQL role provider The link chain of the inherited model is as follows:

Providerbase --> roleprovider--> Sqlroleprovider

 

SQL profile providerThe inherited model chain of is as follows:

Providerbase-> settingsprovider-> profileprovider-> sqlprofileprovider

 

Select an abstract class or an Interface

In ASP. net2.0 You can see the change in Microsoft's design guidelines. In . Net2.0 In earlier versions, they usually use more dependent interfaces to provide template models for framework classes, such Ado. net1.x Data in Provider Class is to execute a common interface ( Idbconnection, idbcommand ). Although Ado. net2.0 continues These interfaces are supported, but this may be for compatibility reasons.

InAdo. net2.0They prefer to select abstract classes.ProviderThe abstract class is used. Instead of using the template generated by the interface, select an abstract class. The possible reasons are:

Abstract classes can execute certain functions, while interfaces cannot.

After the interface is defined, it is not easy to change because the changes will damage the classes defined from the interface.

Abstract classes are used, and the base classes can be non-interfering subclass.

 

Summary: This document provides an in-depth introductionASP. NET providerModel. In the next part of this series, we will use the first, 2Part of the knowledge comes from defining your ownMembershipModel

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.