【问题标题】:How to run IdentityServer and WebAPI in same project如何在同一个项目中运行 IdentityServer 和 WebAPI
【发布时间】:2016-08-15 01:09:50
【问题描述】:

目前我有一个可以完美运行的身份服务器,但我想在其上添加一个 API,以通过 Web 前端进行一些数据库配置更改。文档中的示例展示了如何使用 MVC 而不是 WebAPI。

Startup.Configuration 方法如下所示:

app.UseIdentityServer(new IdentityServerOptions{ ... });

...

app.Map("/api", apiApp =>
{
    apiApp.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
    {
        Authority = "https://localhost:44300", // URL of identity server
    });
});

但是,当app.Map 被调用时,它会抛出一个错误,因为它无法到达身份服务器,可能是因为它还没有启动。我怎样才能让他们一起正常工作?

【问题讨论】:

    标签: c# asp.net-web-api asp.net-identity identityserver3


    【解决方案1】:

    当我在 StackOverflow 上发帖时总是会发生这种情况,我在发帖几秒钟后就知道了!对于遇到此问题的其他人,在

    IdentityServerBearerTokenAuthenticationOptions

    设置

    DelayLoadMetadata = true

    然后一切都会顺利进行!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-13
      • 1970-01-01
      • 2014-01-12
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      • 2013-03-17
      • 2019-10-11
      相关资源
      最近更新 更多