gpt4 book ai didi

asp.net - AspNet Role provider 介入,不应该

转载 作者:行者123 更新时间:2023-12-02 07:40:04 25 4
gpt4 key购买 nike

我收到这个错误:

Line 246:       <roleManager>
Line 247: <providers>
Line 248: <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
Line 249: <add name="AspNetWindowsTokenRoleProvider" applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
Line 250: </providers>

Source File: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config Line: 248

但是,它不应该是因为我们没有使用 aspnetroleprovider。但它在 machine.config 中。其他网站没有这个问题。是什么让它选择了 aspnetsqlroleprovider?

最佳答案

修复

enableSimpleMembership 添加到您的 web.config 应用程序设置中,值为 false

原因

<roleManager enabled="false" />

将导致 Roles.Enabled 标志被设置为 false,正如预期的那样,

但是 'WebMatrix.WebData.WebSecurity' 说:

internal static void PreAppStartInit()
{
if (!ConfigUtil.SimpleMembershipEnabled)
return;
...
Roles.Enabled = true;
const string BuiltInRolesProviderName = "AspNetSqlRoleProvider";
var builtInRoles = Roles.Providers[BuiltInRolesProviderName];
if (builtInRoles != null)
{
var simpleRoles = CreateDefaultSimpleRoleProvider(BuiltInRolesProviderName, currentDefault: builtInRoles);
Roles.Providers.Remove(BuiltInRolesProviderName);
Roles.Providers.Add(simpleRoles);
}
...
}

这将覆盖 roleManager 设置(此代码在 RoleManager 模块之前执行),包括添加 AspNetSqlRoleProvider

要禁用“SimpleMembership”,您可以添加应用设置 enableSimpleMembershipvalue="false" (web.config):

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key="enableSimpleMembership" value="false" />
</appSettings>
</configuration>

这将阻止 webmatrix 重新配置 RoleManager

关于asp.net - AspNet Role provider 介入,不应该,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12116736/

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