Understanding ASP. NET Provider Model-Part 2

Source: Internet
Author: User
Introduction

In the part 1 we learned the basic idea of ASP. net provider model. in this Part I will explain the overall architecture of ASP. net built-in providers. specifically we will be dissecting the membership provider.

The base classes for membership providers

Have a look at figure below:

As you can see, the base class for all the providers is providerbase. the providerbase class resides in system. configuration. provider namespace from system. configuration namespace. this class is marked as abstract and it provides template for further inheritance chain. one of the important method of this class is initialize (). this method is used to read the configuration information of the provider from web. config File and initialize the provider.

The membershipprovider class resides in system. web. security namespace. this class is inherited from the providerbase class and adds membership specific members (especially user creation and management related members) to itself. this class is also marked as abstract.

Finally, sqlmembership class from system. Web. Security inherits the membershipprovider class. This is a concrete class that implements properties and methods from providerbase and membershipprovider specifically for SQL Server databases.

Other provider classes

Similar class hierarchy can be seen for other providers such as SQL role provider and SQL profile provider.

For example, the inheritance chain for SQL role provider is as follows:

Providerbase-> roleprovider-> sqlroleprovider

And the inheritance chain for SQL profile provider is:

Providerbase-> settingsprovider-> profileprovider-> sqlprofileprovider

Abstract classes or interfaces

In. NET 2.0 I see some changes in the design guidelines by Microsoft. in the previous versions. net they used to rely more on interfaces to provide template for framework classes. for example, in ADO. net 1.x all the data provider classes implement certain common interfaces (idbconnection, idbcommand etc .). though ADO. NET 2.0 continues to implement these interfaces It is mainly for the sake of backward compatibility. they have opted for abstract classes in ADO. NET 2.0. the same goes for provider classes. instead of providing template via interfaces they have opted for abstract classes. the possible reasons that I can see are:

    • Abstract classes can provide some implementation which interfaces can not.
    • Interfaces are unalterable once implemented as that will break all the classes that are already implementing the interface.
    • With abstract classes the base class can be evolved without disturbing the child classes that already inherit from it.
Summary

In this article we looked into the structure of built-in ASP. NET providers. In the next article we will develop a custom membership provider using our knowledge of part 1 and 2.

Related Article

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.