ASP.NET: This method cannot be called during the application's pre-start initialization stage

I'm trying to get an ASP.NET MVC 3 site running on IIS 6.0.

Currently when I request a page from the server it gives the following error:

Parser Error Message: This method cannot be called during the application's pre-start initialization stage.

on this line:

<add name="MyMembershipProvider" type="NS.MyMembershipProvider" connectionStringName="MyDatabase" applicationName="/MySite"/>

I'm completely stumped and don't have much of a clue about the ASP.NET application lifecycle, let alone the differences between 6.0 and 7.0. Reading through the MSDN pages on it hasn't seemed to help much.

Does anyone have any insight or any good links for investigation? :)


Add this in your web.config (in the appSettings section):

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

EDIT:

For the ones who ask why, it is a known issue described in the mvc 3 release notes More details here


After upgrading some of my applications from ASP.NET MVC3 to MVC4 I was getting this error. It was a result of the WebMatrix assemblies (WebMatrix.WebData.dll and WebMatrix.Data.dll). I removed those references and assemblies from the /bin directory and that took care of the issue.