【问题标题】:How can i resolve System.String IdentityModel.CryptoRandom.CreateUniqueId(Int32)我如何解决 System.String IdentityModel.CryptoRandom.CreateUniqueId(Int32)
【发布时间】:2020-03-14 20:57:14
【问题描述】:

我想用IdentityServer4 创建令牌,但是当我添加这一行时:

services
    .AddIdentityServer()
    .AddDeveloperSigningCredential() <------ EXCEPTION
    .AddInMemoryApiResources(Config.GetApiResources())
    .AddInMemoryClients(Config.GetClients());

在我的项目中我有这个例外

System.MissingMethodException:'找不到方法:'System.String IdentityModel.CryptoRandom.CreateUniqueId(Int32)'。'

我在我的项目中添加了 .AddDeveloperSigningCredential() 行,因为之前当我运行我的 api 来查看我的令牌时,我遇到了这个错误:

“密钥集丢失”

当我想运行我的 api 时。

我关注this 来创建我的项目。

【问题讨论】:

  • 你更新了 IdentityServer 的包吗?

标签: c# token asp.net-core-webapi identityserver4


【解决方案1】:

我遇到了这个问题,这就是原因:

如果您正在运行 IdentityServer4,版本 2.5.4 或更低版本,并且您引用的项目包含 IdentityModel,版本 4.0.0 或更高版本,您将收到此错误。

希望这对某人有所帮助。

【讨论】:

    【解决方案2】:

    更新IdentityServer 在我的情况下有效。你找到最新版本here.

    【讨论】:

    • 这可能是因为您引用的项目使用的依赖项比您使用的 IdentityServer 版本兼容的新依赖项。升级 IdentityServer 只是对齐了依赖版本
    【解决方案3】:

    你是这样做的吗?

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddIdentityServer()
                .AddDeveloperSigningCredential()....
    

    而且您每次尝试测试时都需要重新启动客户端。 客户端每次会话只拨打一次电话

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-07
      • 2020-03-31
      • 1970-01-01
      • 2012-08-30
      • 2015-07-25
      • 1970-01-01
      相关资源
      最近更新 更多