任务被取消了

Man*_*ari 2 identityserver3

我正在尝试在同一个启动中共同主持identityserver3和web api(用于使用Bearer令牌的用户管理).但是我收到以下错误:任务被取消了.当尝试调用http://identity_local/core/.well-known/openid-configuration(identity_local指向localhost)时,启动时会发生任务取消.

我的创业公司如下:

app.Map("/core", idsrvApp =>
        {
            var factory = new IdentityServerServiceFactory();
            factory.UserService = new IdentityServer3.Core.Configuration.Registration<IUserService, UserService>();
            factory.ScopeStore = new IdentityServer3.Core.Configuration.Registration<IScopeStore>(resolver => scopeStore);
            var options = new IdentityServerOptions
            {
                SigningCertificate = Certificate.Load(),
                IssuerUri = "http://identity_local/core",
                PublicOrigin = "http://identity_local",
                RequireSsl = false, //for now
                Factory = factory,
            };

            idsrvApp.UseIdentityServer(options);
        });

        app.Map("/admin", adminApp =>
        {
            adminApp.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
            {
                Authority = "http://identity_local/core",
                IssuerName = "identity_local",
                ValidationMode = ValidationMode.Local,
                RequiredScopes = new[] { "api", "roles" }
            });

            adminApp.UseResourceAuthorization(new AuthorisationManager());

            var config = new HttpConfiguration();
            config.MapHttpAttributeRoutes();

            adminApp.UseCors(CorsOptions.AllowAll);
            adminApp.UseWebApi(config);

        });
Run Code Online (Sandbox Code Playgroud)

有没有人知道a)是否有可能在同一个创业公司和b)如果是这样,我做错了什么或我能做些什么来弥补上述问题.

Bro*_*len 8

在启动时UseIdentityServerBearerTokenAuthentication尝试联系IdentityServer元数据端点,但由于服务器尚未运行,因此无法连接,因此出现错误.

对于这种情况,有一个标志叫做DelayLoadMetadata延迟加载元数据,直到第一次需要它:https://identityserver.github.io/Documentation/docsv2/consuming/options.html