I'm trying to use the Web Site Administration Tool to configure membership for a web site on my server. I've created an aspnetdb database on my local copy of SQL Server, and through the WSAT, I've managed to add several roles, and to lock down a couple of directories on the server.
However, when I try to manage users, I get the following error:
The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty. at System.Web.Util.SecUtility.GetConnectionString(NameValueCollection config) at System.Web.Security.SqlMembershipProvider.Initialize(String name, NameValueCollection config) at System.Web.Configuration.ProvidersHelper.InstantiateProvider(ProviderSettings providerSettings, Type providerType)
Clearly, the LocalSqlServer connection string is OK, otherwise I wouldn't have been able to add the roles, for example.
The relevant parts of web.config are as follows:
<connectionStrings>
<clear />
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=(local);Initial Catalog=aspnetdb;User Id=LoginUser;Password=password;" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" defaultUrl="~/admin/admin.aspx" />
</authentication>
<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
<providers>
<clear />
<add
name="SqlProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="LocalSqlServer"
applicationName="myapp" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="myapp" />
</providers>
</profile>
<roleManager enabled="true">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="myapp" />
</providers>
</roleManager>
</system.web>
As far I understand it, the Clear/Remove elements should override any other config files, but regardless, I tried adding the same connection string to the relevant machine.config, but to no avail.
Any ideas?
As an alternative, is there any reason why I can't call the Membership DB stored procedures directly? Does anyone know of any supporting documentation?