O'Reilly logo

Professional ASP.NET 3.5 Security, Membership, and Role Management with C# and VB by Stefan Schackow, Bilal Haidar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

10.4. Building a Provider-Based Feature

Now that you have seen the rationale and architecture behind provider-based features, walking through the basic steps of writing a simple provider-based feature along with a custom provider will help you tie together the previous concepts to the provider support classes in both the 2.0 and 3.5 Frameworks. In this section, you will walk through the steps of building a provider-based feature, as shown in Figure 10-1.

Figure 10-1. Figure 10-1

Because the intent of this section is to concentrate on creating a provider-based feature, the feature used for the sample will define and implement only one method that simply requests a string from its default provider. The sample provider base class definition is:

C#

using System;
using System.Configuration.Provider;

namespace SampleFeature
{
    public abstract class SampleFeatureProvider : ProviderBase
    {
        //Properties
        public abstract string Color { get; }
        public abstract string Food { get; }

        //Methods
        public abstract string GetMeAString(string andPutThisOnTheEndOfIt);
    }
}

VB.NET

Imports Microsoft.VisualBasic
Imports System
Imports System.Configuration.Provider
Namespace SampleFeature Public MustInherit Class SampleFeatureProvider Inherits ProviderBase 'Properties Public MustOverride ReadOnly Property Color() As String Public MustOverride ReadOnly Property Food() As String 'Methods Public MustOverride ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required