views:

110

answers:

1

I have to confess that I hate membership provider. The default implementation is not very appropriate normally and I haven't seen so far a good implementation of a custom membership provider, probably because this is not possible :-)

So the question is:

In your opinion: which are the reasons for not having membership/role provider as a generic class? I mean, why Microsoft didn't select this approach.

EDIT

Reading the answer I realized that maybe it wasn't clear enough that I'm talking about MembershipProvider and RoleProvider. NOT about the core authentication mechanism of ASP NET.

+3  A: 

The most obvious reasons that come to mind are:

  • The default classes are sufficient for most purposes (mainly: user management, authentication, and permission checks);

  • The system is already extensible through inheritance (implement IPrincipal).

  • The membership system was designed for the .NET 1.1 Framework, before generics were available.

Aaronaught
@Aaronaught: Thanks for your answer. Membership provider's methods returns a MembershipUser instance. if you want to return something else, you have to inherits from this class and cast it outside. No method return an interface :-(
Timmy O' Tool
@Timmy: Perhaps you should read some of the documentation. http://msdn.microsoft.com/en-us/library/aa480476.aspx
Aaronaught
@Aaronaught: Thanks again. How that documentation is connected with MembershipProvider?
Timmy O' Tool
@Timmy: Scroll down to `FormsAuthenticationModule` where it explains how to use the `IPrincipal` interface. There's a whole architecture here, `MembershipProvider` isn't supposed to be used in isolation.
Aaronaught
@Downvoter: I'd love to hear the explanation for *this* downvote.
Aaronaught
FYI: If you need more information on implementing `IPrincipal`, there's a tutorial here: http://msdn.microsoft.com/en-us/library/Aa302401
Aaronaught