Hi,
When the application doesn't use Roles, this configuration (web.config)
works:
<configuratio n>
<connectionStri ngs>
<clear/>
<add name="myconn" connectionStrin g="Data Source=.\sqlexp ress;Initial
Catalog=mydb;In tegrated Security=True"
providerName="S ystem.Data.SqlC lient"/>
</connectionStrin gs>
....
<membership>
<providers>
<remove name="AspNetSql MembershipProvi der"/>
<add name="AspNetSql MembershipProvi der"
type="System.We b.Security.SqlM embershipProvid er, System.Web,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b03f5f7f11d50a3 a"
connectionStrin gName="myconn" />
</providers>
</membership>
....
When i use Roles with this web.config:
------------------------------------------------------
<configuratio n>
<connectionStri ngs>
<clear/>
<add name="myconn" connectionStrin g="Data Source=.\sqlexp ress;Initial
Catalog=mydb;In tegrated Security=True"
providerName="S ystem.Data.SqlC lient"/>
</connectionStrin gs>
<system.web>
<authorizatio n>
<allow roles="role1"/>
<allow roles="role2"/>
</authorization>
<roleManager enabled="true">
<providers>
</providers>
</roleManager>
....
<membership>
<providers>
<remove name="AspNetSql MembershipProvi der"/>
<add name="AspNetSql MembershipProvi der"
type="System.We b.Security.SqlM embershipProvid er, System.Web,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b03f5f7f11d50a3 a"
connectionStrin gName="myconn" />
</providers>
</membership>
....
I get this error: "The connection name 'LocalSqlServer ' was not found in the
applications configuration or the connection string is empty"
line 149: <add name="AspNetSql RoleProvider"
connectionStrin gName="LocalSql Server" applicationName ="/" ...
Source File:
C:\WINDOWS\Micr osoft.NET\Frame work\v2.0.50727 \Config\machine .config line 149
I solved this by adding in web.config this line: <add name="LocalSqlS erver"
connectionStrin g="Data Source=.\sqlexp ress;Initial Catalog=mydb;In tegrated
Security=True" providerName="S ystem.Data.SqlC lient"/>
But i would like understand what happened.
Why do i have to add the second connectionStrin g "LocalSqlServer " only when
using Roles? Whats' the meaning of that error in machine.config?
Thanks
Vincent
When the application doesn't use Roles, this configuration (web.config)
works:
<configuratio n>
<connectionStri ngs>
<clear/>
<add name="myconn" connectionStrin g="Data Source=.\sqlexp ress;Initial
Catalog=mydb;In tegrated Security=True"
providerName="S ystem.Data.SqlC lient"/>
</connectionStrin gs>
....
<membership>
<providers>
<remove name="AspNetSql MembershipProvi der"/>
<add name="AspNetSql MembershipProvi der"
type="System.We b.Security.SqlM embershipProvid er, System.Web,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b03f5f7f11d50a3 a"
connectionStrin gName="myconn" />
</providers>
</membership>
....
When i use Roles with this web.config:
------------------------------------------------------
<configuratio n>
<connectionStri ngs>
<clear/>
<add name="myconn" connectionStrin g="Data Source=.\sqlexp ress;Initial
Catalog=mydb;In tegrated Security=True"
providerName="S ystem.Data.SqlC lient"/>
</connectionStrin gs>
<system.web>
<authorizatio n>
<allow roles="role1"/>
<allow roles="role2"/>
</authorization>
<roleManager enabled="true">
<providers>
</providers>
</roleManager>
....
<membership>
<providers>
<remove name="AspNetSql MembershipProvi der"/>
<add name="AspNetSql MembershipProvi der"
type="System.We b.Security.SqlM embershipProvid er, System.Web,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b03f5f7f11d50a3 a"
connectionStrin gName="myconn" />
</providers>
</membership>
....
I get this error: "The connection name 'LocalSqlServer ' was not found in the
applications configuration or the connection string is empty"
line 149: <add name="AspNetSql RoleProvider"
connectionStrin gName="LocalSql Server" applicationName ="/" ...
Source File:
C:\WINDOWS\Micr osoft.NET\Frame work\v2.0.50727 \Config\machine .config line 149
I solved this by adding in web.config this line: <add name="LocalSqlS erver"
connectionStrin g="Data Source=.\sqlexp ress;Initial Catalog=mydb;In tegrated
Security=True" providerName="S ystem.Data.SqlC lient"/>
But i would like understand what happened.
Why do i have to add the second connectionStrin g "LocalSqlServer " only when
using Roles? Whats' the meaning of that error in machine.config?
Thanks
Vincent
Comment