Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 什么是ProfileService/何时执行ProfileService?_C#_Asp.net_Asp.net Core_Identityserver4_Oidc Client Js - Fatal编程技术网

C# 什么是ProfileService/何时执行ProfileService?

C# 什么是ProfileService/何时执行ProfileService?,c#,asp.net,asp.net-core,identityserver4,oidc-client-js,C#,Asp.net,Asp.net Core,Identityserver4,Oidc Client Js,我一直在玩IdentityServer 4。绝对喜欢 我一直在浏览你网站上的教程,特别是 我创建了一个配置文件服务,该服务执行以下操作: public class ProfileService : IProfileService { public Task GetProfileDataAsync(ProfileDataRequestContext context) { context.IssuedClaims.Add(new Claim("test-claim",

我一直在玩IdentityServer 4。绝对喜欢

我一直在浏览你网站上的教程,特别是

我创建了一个配置文件服务,该服务执行以下操作:

public class ProfileService : IProfileService
{
    public Task GetProfileDataAsync(ProfileDataRequestContext context)
    {
        context.IssuedClaims.Add(new Claim("test-claim", "test-value"));
        return Task.FromResult(0);
    }

    public Task IsActiveAsync(IsActiveContext context)
    {
        context.IsActive = true;

        return Task.FromResult(0);
    }
}
这非常有效,我的自定义声明可以在我的JS客户端的日志窗口中看到

我在它上面放了一个断点,只是为了检查上下文中的内容,我注意到它被击中了两次。调用方属性分别是
ClaimsProviderAccessToken
UserInfoEndpoint
。为什么会这样

在我的天真中,我从我的js客户端删除了
profile
范围,在oidc js config中也删除了profile范围,并设置了
loadUserInfo:false
,但我的
ProfileService
仍然被调用了两次


如果我的最终目标是根据数据库中的参数设置声明,我真的不想做两次这个操作,是吗?(真正的问题——我不知道)。“解决方案”是只将它们设置在“ClaimsProviderAccessToken”上但是有东西告诉我,ProfileServices会被调用两次是有原因的,在两次运行中设置声明是很重要的。

只要IdentityServer需要向客户端应用程序返回关于用户的声明,就会调用ProfileService


如果您请求一个标识和访问令牌-它将被调用两次(因为您可能会对每种令牌类型提出不同的声明)。

仅适用于您希望命令与DotNet命令一起在中可用的情况,即
DotNet ef数据库更新
Microsoft.EntityFrameworkCore.Tools
仍然存在并可用,但仅在package manager控制台中可用(Powershell命令,如
Migration Add
Database Update
,如EF6等早期版本中所用)。也看到