Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Interesting blog
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Interesting blog
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01382913
Message ID:
01382913
Vues:
139
Hi everybody,

This is what I just got by e-mail from one of our .NET Meetup people. You may be interested to take a look as well (I plan to check it later myself).
------------------------------------------------------------------------------------------------------------------------------------------------------------------
I'm interested to hear what people think about a MembershipProvider I'm writing for a new project.

If you don't mind taking a look at my blog post titled "Custom MembershipProvider using Repository & Dependency Injection pattern magic":

http://noahblu.wordpress.com/2009/02/19/custom-membershipprovider-using-repository-dependency-injection-pattern-magic/

Basically I never loved the way Providers were handled. The fact that MS bundles a SqlMembershipProvider implies that you need 1 for each different server type. And what about when you want a different table structure? And what about integrating with your existing business objects? And what about testing?

I decided to create a custom MembershipProvider for a new project I'm working on. I wanted it to make up for all the flaws I saw in the default providers. Instead of a SqlMembershipProvider and an NHibernateMembershipProvider (I've seen this somewhere on Codeplex) and a whole lot of other providers for each type of database, there's just 1 MembershipProvider that takes any IMembershipRepository.
I thought it would take 5 min but actually it took longer because I had to figure out why something wasn't working. Turns out you can't just create a new constructor for the MembershipProvider that takes an IMembershipRepository argument because of the way the Provider will be magically instantiated out of your web.config like a rabbit out of thin air. There's a whole Initialize() method at play here and if you don't play right you can't test it (because MembershipUser relies on having a proper ProviderName passed in). Long story short I had to do some research to find out how this works and I'm ashamed to say that all in all this very simple thing took me an hour.
Even so, I think it's awesome. What I'm left with is a very extensible MembershipProvider that's easily testable. Has nobody done this before? It seems so obvious to me now...

I'd love to hear what you think!

- Noah
If it's not broken, fix it until it is.


My Blog
Répondre
Fil
Voir

Click here to load this message in the networking platform