MVC Web Application Error: ‘LocalSqlServer’ was not found

I created a new MVC Web Application and added a new Windows Azure Cloud Service project to the solution. The project was able to build successfully, and the Cloud project tested successfully, but when I tested the web app, I received the following error: Parser Error Message: The connection name ‘LocalSqlServer’ was not found in the applications configuration or the connection string is empty. Here is the entire message:

Server Error in ‘/’ Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: The connection name ‘LocalSqlServer’ was not found in the applications configuration or the connection string is empty.

Source Error:

Line 248:		<membership>
Line 249:			<providers>
Line 250: <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/> Line 251:				<add name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.3.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
Line 252:			</providers>

Source File: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config Line: 250

I’ve dealt with missing connection strings before, but this was different, I had no database or other connections to worry about. I removed the offending providers from the machine.config file, but I received the same error. The web.config was no help – it was too basic to have caused this error. Luckily, after about an hour, I stumbled across a great article that fixed the problem. Here is the fix, add this to your web.config under appSettings:

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

It seems this WebMatrix Simple Membership is enabled by default. I then found an article from Microsoft that describes this further. I’ll look into this later, but what a relief to have that problem solved.

Leave a Reply