I recently began using Visual Studio 2012 for new projects. I ran into a Visual Studio 2012 ASP.NET 4.5 Custom Membership Provider Error for my application using MVC 4. After adding the custom membership provider and hooking up the Web.config, the web application failed to load with the following Yellow Screen of Death error.This method cannot be called during the application’s pre-start initialization phase.
The funny thing here is that this configuration worked fine in VS 2010 projects and the same Web.config options. What changed with VS 2012 and/or ASP.NET 4.5? It looks like there is a new SimpleMembership provider for ASP.NET 4.5 and this causes the problem with the old custom membership provider approach. You can fix the issue and preserve your existing code using the configuration option below in the appSettings section of your Web.config file.[sourcecode language=”xml”]
<add key=”enableSimpleMembership” value=”false”/>
It might be worth investigating the SimpleMembership provider as it replaces the fairly complicated ASP.NET Role and Membership provider system. Get more information about the custom membership provider on StackOverflow.