Correct the Custom Membership Provider Error in Visual Studio 2012 and ASP.NET 4.5

Correct the Custom Membership Provider Error in Visual Studio 2012 and ASP.NET 4.5

I recently began using Visual Studio 2012 for new projects and I ran into a problem implementing a custom membership provider for an ASP.NET 4.5 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”]

<appSettings>
<add key="enableSimpleMembership" value="false"/>
</appSettings>

[/sourcecode]

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.

No Comments Yet.

Leave a reply

You must be logged in to post a comment.

Sign in
classic
Forgot password?
×
Sign up

(*) Required fields

I agree with OptimaSales Terms & Privacy Policy

×