Elegant Asp.Net MVC 3 custom membership wrapper class with extended (custom) methods and properties

StackOverflow https://stackoverflow.com/questions/5966575

Question

I am attempting to write a custom membership class. It seems to work ok inhering the Membership class and providing functions for all the included required items (validate user, create user, delete user, isapproved, etc).

However, where I run into a problem is when I try to add properties or methods.

As all the other properties and methods are public override classes in a sealed class, the additional properties do not show up.

Say for example (example only, not "real" code):

public sealed class Membership : MembershipProvider
{
    public override string ApplicationName
    {
        get
        {
            return "myApp";
        }
    }
    public string myValue { get;set;}
}

Now, I understand why myValue will not show up when I try to do Membership.myValue but Membership.ApplicationName will.

My question is, how to extend membership to show the custom items? Do I ditch Membership.xxx entirely and write a wrapper class? If so, how? I can find all the documentation in the world on how to create a custom membership class. I've got a working custom membership that works fine if I use all the available options only. I've got a custom roles provider and a custom config section to store everything and it's best friend.

What I don't have is an elegant solution.

I'd like the end result to be that I use one reference (such as Membership.xxx or myClass.xxxx) to reference all membership items + custom items.

Please provide examples of how to implement or links to appropriate items that will resolve the custom methods item.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top