我正在使用 ASP.NET 5,在我的解决方案中,我有 Web API、Identity Server 和 Angular 2 项目,我正在使用 Identity Server 对 Angular 2 客户端进行身份验证,Angular 2 客户端通过在 http 请求中传递 token 来使用 Web API,并且web api 验证 token 并给出响应,为此我编写了一个自定义属性来检查用户是否已通过身份验证
当我使用 API 时出现以下异常并且 Web API 返回 500 内部服务器错误。
System.InvalidOperationException: IDX10803: Unable to obtain configuration from: 'http://xx.xx.xx.x:3926/.well-known/openid-configuration'. ---> System.IO.IOException: IDX10804: Unable to retrieve document from: 'http://xx.xx.xx.x:3926/.well-known/openid-configuration'. ---> System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond xx.xx.xx.x:3926 at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
最佳答案
如果身份服务器和访问 token 验证中间件托管在同一应用程序中,则在启动时会出现竞争条件。
验证中间件尝试加载尚不可用的发现文档。
在这些情况下,将验证中间件上的 DelayLoadMetadata
标志设置为 true。
如果您完全禁用发现端点,则需要在验证选项上配置颁发者和 key Material 。
关于angular - 无法从 well-known/openid-configuration 获取配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37693516/