任务已取消

编程入门 行业动态 更新时间:2024-10-23 07:21:58
本文介绍了任务已取消的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试在同一启动中共同托管Identityserver3和Web api(用于使用Bearer令牌的用户管理).但是我收到以下错误: 任务已取消. 似乎在尝试调用 identity_local/core/.well时,启动时发生了任务取消-known/openid-configuration (identity_local指向本地主机).

I am trying to co-host identityserver3 and web api (for user management using Bearer tokens) in the same startup. However I get the following error: A task was canceled. It appears the task cancellation occurs on startup when trying to call identity_local/core/.well-known/openid-configuration (identity_local points to 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 = "identity_local/core", PublicOrigin = "identity_local", RequireSsl = false, //for now Factory = factory, }; idsrvApp.UseIdentityServer(options); }); app.Map("/admin", adminApp => { adminApp.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions { Authority = "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); });

有人知道a)是否可以在同一启动中同时运行b)如果是这样,我做错了什么或者我该怎么做才能解决上述问题.

Does anyone know if a) it is possible to have both in the same startup and b) if so, what have I done wrong or what can I do to remedy the above.

推荐答案

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

At startup time the UseIdentityServerBearerTokenAuthentication tries to contact the IdentityServer metatadata endpoint, but since the server is not yet running it can't connect, thus an error.

在这种情况下,有一个名为DelayLoadMetadata的标志将元数据的加载延迟到第一次需要时: identityserver.github.io/Documentation/docsv2/using/options.html

For this situation, there's a flag called DelayLoadMetadata to delay load the metadata until the first time it's needed: identityserver.github.io/Documentation/docsv2/consuming/options.html

更多推荐

任务已取消

本文发布于:2023-11-08 07:04:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1568678.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!