The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.

Jul 12, 2007 at 5:20 PM
On my production server I'm getting the following message ( I don't get it on the dev server) when I login with admin user



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 115: <membership>
Line 116: <providers>
Line 117: <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.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 118: </providers>
Line 119: </membership>


Source File: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config Line: 117

Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42


Any ideas ?

Thanks,
Gavin
Jul 13, 2007 at 1:38 PM
That is the default membership configuration for ASP.NET applications, you can one of the following to correct it:

-- Sql Membership
If you are using the SqlMembershipProvider you can either change the name of your connection string node to LocalSqlServer like so:
<connectionStrings>
<add name="LocalSqlServer" connectionString="Your ConnStr"/>
</connectionStrings>

or clear the providers in the membership node and re-add for your connectionString:
<connectionStrings>
<add name="YourConnStrName" connectionString="Your ConnStr"/>
</connectionStrings>

<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="YourConnStrName" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
</providers>
</membership>


-- Xml Membership
If you are using the XmlMembershipProvider supplied with BlogEngine.NET then just add the <clear/> node in your web.config like so:
<membership defaultProvider="XmlMembershipProvider">
<providers>
<clear />
<add name="XmlMembershipProvider" type="BlogEngine.Core.Providers.XmlMembershipProvider" description="XML membership provider" xmlFileName="~/App_Data/users.xml"/>
</providers>
</membership>


Using the <clear/> node will clear out inherited values and is a better practice than editing your machine.config.

Hope this helps,
-Cameron
Jul 13, 2007 at 3:14 PM
Kwel!

<clear/> did it. Thanks :-)

Gavin :-)
Oct 10, 2007 at 7:48 AM
Edited Oct 10, 2007 at 11:23 AM
>>"Using the <clear/> node will clear out inherited values and is a better practice than editing your machine.config."

I'm trying to upgrade my staging server from 1.1 to 1.2, changing nothing else other than the version of BlogEngine. I'm using the default XML provider, although I do have a SQL database on the machine also, I'm not currently using it for BlogEngine, which is just a default XML install. I get the following error, both on IIS6 and IIS7 machines (I tried both..).

My process was:
(a) stop the server; (b) back up my app_data; (c) remove old BlogEngine.Net directory structure; (d) replace with new structure from 1.2 release, set permissions, create application; (e) Attempt to start system to confirm all is good (that is: no recovery of old data or users at this point.

I'm getting this error message:
The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.

_Source Error:
Line 186: <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/"
Line 187: type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

Which is fair enough, as I haven't put any connexion string anywhere near BlogEngine. The release web.config does have the "<Clear />" line already in it in the membership provider section, so that fix doesn't look useful to me. I don't have a SQL member provider listed there at all; it's pulling this from the machine.config.

I tried to comment out the MSSQLBlogProvider line from the <blogProvider> section, but that doesn't do nufink.

Any suggestions please...? Something's changed here..

Other information which may be relevant:
- this application is running as a part of a larger web site.
Oct 10, 2007 at 11:15 AM
Try adding <clear/> to the roles provider, this worked for me when I upgraded to 1.2


<membership defaultProvider="XmlMembershipProvider" >
<providers>
<clear />
<add name="XmlMembershipProvider" type="BlogEngine.Core.Providers.XmlMembershipProvider" description="XML membership provider" xmlFileName="~/App_Data/users.xml"/>
</providers>
</membership>

<roleManager defaultProvider="XmlRoleProvider" enabled="true">
<providers>
<clear/>
<add name="XmlRoleProvider" type="BlogEngine.Core.Providers.XmlRoleProvider" description="XML role provider" xmlFileName="~/App_Data/roles.xml"/>
</providers>
</roleManager>
Oct 10, 2007 at 11:36 AM
..more. I dug out my machine.config and compared it to the default file, which MS leave in the same directory. The difference is a block of stuff which doesn't seem to be relevant to this, so I don't think that's it. Looking in there, there's the "connection string" LocalSqlServer, which points at SQLEXPRESS (correct), but the rest of that looks like standard template stuff which probably won't work on my instance. But I don't want it to anyway.

So taking a look at the line which references this, it's in this section...
<roleManager>
<providers>
<add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/"
type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add name="AspNetWindowsTokenRoleProvider" applicationName="/"
type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</roleManager>

It's AspNetSqlRoleProvider (not membership) which is causing my reference to the LocalSqlServer. Hmm, so what if I try the <clear/> trick on that, as follows:

<roleManager defaultProvider="XmlRoleProvider" enabled="true">
<providers>
<clear />
<add name="XmlRoleProvider" type="BlogEngine.Core.Providers.XmlRoleProvider" description="XML role provider" xmlFileName="~/App_Data/roles.xml"/>
</providers>
</roleManager>

Ok, that kind of works in that it removes this error, but then I get a different one... it's now whining about failing to load a custom sitemap provider from my website's own web.config. Hmm.. so I have:

website
contains web.config, works fine
website/BogEngine.Net
contains web.config, works fine on 1.1 but blows up as above on 1.2
website/YAF
Works ok with web.config.

I realize this is something to do with my configuration, not specifically a BlogEngine issue, but it used to work with 1.1 and perhaps someone can shed some light on it. I promise to post any useful data to the wiki.

I thought the whole application deal meant that the web.config of the application was used, not the one of the parent website. It seems that's wrong. I'll take the sitemap provider out and see if there are any other errors.
Oct 10, 2007 at 11:42 AM
F knows what's happening with the list in this forum - the posts are coming up in a strange order.

Anyway, in the true spirit of solving your own problems, of which I'm sure you'll approve, I think I just solved this one by using the fact provided by the chap higher up the thread...

I don't understand what's happening here, but the deal is that the BlogEngine.NET's web.config somehow "inherits" stuff from the parent website's web.config. In my case this last problem was because in that parent site web.config I have a custom sitemap provider, which the BlogEngine.Net could not see and therefore barfed about. The solution: stick the <clear/> magic word in the Site Map Providers section of the BlogEngine.Net, and it starts up.

Phew. I'm not sure I should wiki that because maybe it's just me who has this running in this way. Anyway, sorted. That's for listening ;-)