I am trying to use ASP.NET MVC4 to manage Forms Authentication and OAuth (Facebook), and take care of the browser sessions.
Yet I would like to manage all the users's data (and actually all the data) in a NoSQL data store. Since I already have a Data Access Layer library for that store, I thought I should not use Entity Framework at all.
My thought was: 1. Disable EntityFramework, all "default" data connections and tables used to implement "Membership". 2. Implement my own provider on top of NoSQL, by inheriting my own provider class from SimpleMembershipProvider (to support both Forms and OAuth authentication) 3. Configure system not to use Roles provider for now (no requirements to manage roles yet)
Unfortunately, I wasn't able to do "Step 1", i.e. get read from all the default connections and tables.
I did manage to register and use my own SimpleMembershipProvider implementation, but there is some code around that keeps calling the "default connection".
Example of exception I am getting with my provider, when disabling RoleManager in the web.config:
InnerException: System.InvalidOperationException
HResult=-2146233079
Message=The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588
Source=MvcApplication5
StackTrace:
at MvcApplication5.Filters.InitializeSimpleMembershipAttribute.SimpleMembershipInitializer..ctor() in c:\Users\max\Documents\Visual Studio 2012\Projects\MvcApplication2\MvcApplication5\Filters\InitializeSimpleMembershipAttribute.cs:line 45
InnerException: System.Configuration.Provider.ProviderException
HResult=-2146233088
Message=The Role Manager feature has not been enabled.
Source=System.Web
StackTrace:
at System.Web.Security.Roles.EnsureEnabled()
at System.Web.Security.Roles.get_Provider()
at WebMatrix.WebData.WebSecurity.InitializeProviders(DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables)
at WebMatrix.WebData.WebSecurity.InitializeDatabaseConnection(String connectionStringName, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables)
at MvcApplication5.Filters.InitializeSimpleMembershipAttribute.SimpleMembershipInitializer..ctor() in c:\Users\max\Documents\Visual Studio 2012\Projects\MvcApplication2\MvcApplication5\Filters\InitializeSimpleMembershipAttribute.cs:line 41
InnerException:
What's the recommended way of doing that? (in web.config?) If there is a fundamental flaw or misunderstanding in my plan, please let me know.
Thanks for any hint.
SimpleMembershipProvider doesn't use Entity Framework. Instead, it has own SQL operations.
You can look at the source of SimpleMembershipProvider.cs
If you want to implement a custom provider (to support both Forms and OAuth authentication), you want to override ExtendedMembershipProvider by coping some codes from SimpleMembershipProvider.
Copied the image from - SimpleMembership, Membership Providers, Universal Providers and the new ASP.NET 4.5 Web Forms and ASP.NET MVC 4 templates
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments