Introduction to ASP.NET 2.0 Provider Model
page 2 of 5
by Joydip Kanjilal
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 25849/ 73

The Provider Model of ASP.NET 2.0

You no longer have to depend on the web.config file (the application’s configuration file) for defining roles in your application. With ASP.NET 2.0 around, you have support for Membership and Role provider classes, like, the SqlMembershipProvider and SqlRoleProvider. However, the only constraint is that these are designed to work with SQL Server only. No worries; you can extend these classes to create your own custom provider implementations with support for any data store. We would learn more on Providers and their types in the sections to follow.

The ASP.NET Provider Model provides a pluggable architecture for working with providers. You can have the flexibility of using the custom providers; you can even implement your own providers in your applications. Well, what is a provider, anyway? The applications need some way of storing states, either in the temporary main memory or in a persistent manner in the database. "A provider is a software module that provides a uniform interface between a service and a data source. Providers abstract physical storage media, in much the same way that device drivers abstract physical hardware devices."

The Membership and the Role Management Providers follow the provider pattern through the usage of an interface for a contract based approach. The base class for all the providers in such a pattern is the ProviderBase abstract class. All the other providers are actually inherited from this ProviderBase abstract class. The MembershipProvider and the RoleProvider classes that inherit the ProviderBase class are also abstract classes. David Hayden says, "the theory of the pattern is that it allows us to define a well-documented, easy-to-understand API, such as our new Whidbey Membership API's, but at the same time give developers complete control over the internals of what occurs when those API's are called."

Objectives of the ASP.NET 2.0 Provider Model

The following lists the basic objectives of the ASP.NET 2.0 Provider Model.

·         Facilitate designing and developing custom providers seamlessly

·         Promotes flexibility, re-usability and extensibility in ASP.NET state storage  

Benefits of the ASP.NET 2.0 Provider Model

The Provider Model offers benefits in more ways than one. These are as follows.

·         It can be used with the default implementation and customized too.

·         Provides a distinct isolation of code and the back-end implementation.

·         Facilitates isolation of tasks within the project team members.

The ProviderBase class

The following is the list of the methods and properties of the ProviderBase class in the ASP.NET 2.0 Provider Model.

·         Name

·         Description

·         Initialize()

·         ProviderBase()  This is the constructor for the ProviderBase class.

The ProviderBase class is present in the System.Configuration.Provider namespace. This class contains two properties and two methods. The following is the source code for this class.

Listing 1

public class ProviderBase
{
  public virtual string Name
  {
    get;
  }
  public virtual string Description
  {
    get;
  }
  public virtual void Initialize(string name, NameValueCollection config);
}     

The "Name" property implies the name of the provider while the "Description" property relates to the description of the provider.

We will discuss more on the various providers in the ASP.NET Provider Model in the sections that follow.


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-05-18 8:56:20 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search