gpt4 book ai didi

c# - ASP.NET 成员资格和角色提供者配置问题

转载 作者:行者123 更新时间:2023-12-03 21:14:42 25 4
gpt4 key购买 nike

我在尝试启动我的应用程序时收到一条错误消息,我认为我的 web.config 文件中存在错误(见下文)。我已将我的 MembershipProvider 模式与我现有的 RESTAURANT 数据库结合起来。

我有 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=&quot;data source=SFP\SFP_SQL_SVR;attachdbfilename=C:\Users\Susan\Documents\Databases\Restaurants.mdf;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;"
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>

最佳答案

<roleManager><membership><system.web> 的 child

试试这个:

<?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=&quot;data source=SFP\SFP_SQL_SVR;attachdbfilename=C:\Users\Susan\Documents\Databases\Restaurants.mdf;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" 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>

参见:http://msdn.microsoft.com/en-us/library/ms228147.aspx

参见:http://msdn.microsoft.com/en-us/library/dayb112d.aspx

关于c# - ASP.NET 成员资格和角色提供者配置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10251979/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com