Swapping a membership provider
Wednesday, June 10, 2009 6:42:02 AM
It is always a good idea to hide your membership-related activity behind a service, instead of just using the MS provided API. However, I am currently building a prototype, and I wanted to use the built-in controls, which leaves me no choice but use the Membership API.
Turned out it's quite simple, you don't even have to create an aspect:
Dim section As MembershipSection = _
ConfigurationManager.GetSection("system.web/membership")
section.Providers.Add(New ProviderSettings("InMemory", _
"Tests.Membership.InMemoryMembershipProvider"))
section.DefaultProvider = "InMemory"
Here I add my custom provider to the configuration and set it as default.
Of course, this simplicity shouldn't fool you that this is a good idea in general.
codeproject
Copyright 2008 by me