gpt4 book ai didi

asp.net-core - 在 web.config 中未检测到 system.identityModel

转载 作者:行者123 更新时间:2023-12-01 03:27:48 53 4
gpt4 key购买 nike

我有一个 ASP.NET Core 1.0 项目正在运行。当我将 ClaimsPrinciplePermission 属性添加到我的操作方法时,我在导航到具有该属性的任何操作方法时收到以下错误。

An exception of type 'System.InvalidOperationException' occurred in System.IdentityModel.Services.dll but was not handled in user code

Additional information: ID7024: Use of ClaimsPrincipalPermission attribute has been attempted and possibly there is no configuration section defined, see inner exception for details. Also make sure a ClaimsAuthorizationManager element is defined under the section.



这是内部异常

ID7027: Could not load the identity configuration because no configuration section was found.



这是我的 web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>

<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->

<configSections>
<section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</configSections>

<system.identityModel.services>
<federationConfiguration>
<cookieHandler requireSsl="false" />
</federationConfiguration>
</system.identityModel.services>
<system.identityModel>
<identityConfiguration>
<claimsAuthorizationManager type="wApp.ClaimManager, wApp" />
</identityConfiguration>
</system.identityModel>

<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>




</configuration>

如您所见,我已经添加了所有必需的部分。相同的代码和配置在我的 MVC 5 项目和我的 Web Api 项目中运行良好。在 Asp.Net Core 项目中有什么不同的事情要做吗?

我还在 Core 1.0 MVC 项目中添加了所需的 DLL 引用,并在 Core 1.0 MVC 项目下的 App.config 文件中复制了相同的配置部分。仍然得到同样的错误。

我错过了什么?

最佳答案

ClaimsPrincipalPermission 和 WIF/System.IdentityModel 根本不是 .NET Core 的一部分。我很惊讶甚至可以编译。

从评论看来,您正在解析 JWT,大概是使用 JWT 不记名 token 中间件。

因此,ASP.NET Core 中的所有身份都是 ClaimsIdentities。你可以去Simple claims based checks ,或者,更完整地到 code expressed policies这提供了更多的灵活性。

关于asp.net-core - 在 web.config 中未检测到 system.identityModel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40046321/

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