我在尝试启动应用程序时收到错误,并且我认为我的web.config
文件中存在错误(请参阅下文)。我已将MembershipProvider架构与现有的RESTAURANT DB结合使用。
我有2个连接字符串,一个是LINQ to Entities,我用它来填充我的应用程序的餐馆数据,另一个是SQL Server 2008 R2连接,用于成员资格和角色提供者。
我收到的错误是在开头的行:role manager =“true”
这是我的Web.Config
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<appSettings></appSettings>
<connectionStrings>
<add name="RestaurantDB"
connectionString="data source=SFP\SFP_SQL_SVR;attachdbfilename=C:\Users\Susan\Documents\Databases\Restaurants.mdf;Initial Catalog=Restaurants.mdf;Integrated Security=SSPI;"/>
<add name="RestaurantsEntities"
connectionString="metadata=res://*/Restaurant.csdl|res://*/Restaurant.ssdl|res://*/Restaurant.msl;provider=System.Data.SqlClient;provider connection string="data source=SFP\SFP_SQL_SVR;attachdbfilename=C:\Users\Susan\Documents\Databases\Restaurants.mdf;integrated security=True;multipleactiveresultsets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>
<roleManager enabled="true"
defaultProvider="CustomizedRoleProvider">
<providers>
<add name="CustomizedRoleProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="RestaurantsDB" />
</providers>
</roleManager>
<membership defaultProvider="CustomizedMembershipProvider">
<providers>
<add name="CustomizedMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="RestaurantsDB" />
</providers>
</membership>
</configuration>
答案 0 :(得分:3)
您正在指定
<add name="RestaurantDB"
错误
connectionStringName="RestaurantsDB" />
正确
connectionStringName="RestaurantDB" />
如果这个解决了,那就为我祈祷
答案 1 :(得分:3)
<roleManager>
和<membership>
是<system.web>
试试这个:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<appSettings>
</appSettings>
<connectionStrings>
<add name="RestaurantDB" connectionString="data source=SFP\SFP_SQL_SVR;attachdbfilename=C:\Users\Susan\Documents\Databases\Restaurants.mdf;Initial Catalog=Restaurants.mdf;Integrated Security=SSPI;"/>
<add name="RestaurantsEntities" connectionString="metadata=res://*/Restaurant.csdl|res://*/Restaurant.ssdl|res://*/Restaurant.msl;provider=System.Data.SqlClient;provider connection string="data source=SFP\SFP_SQL_SVR;attachdbfilename=C:\Users\Susan\Documents\Databases\Restaurants.mdf;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<roleManager enabled="true"
defaultProvider="CustomizedRoleProvider">
<providers>
<add name="CustomizedRoleProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="RestaurantsDB" />
</providers>
</roleManager>
<membership defaultProvider="CustomizedMembershipProvider">
<providers>
<add name="CustomizedMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="RestaurantsDB" />
</providers>
</membership>
</system.web>
</configuration>