调试运行期间无法识别UseHeaderPropagation

问题描述 投票:0回答:1

我正在努力向 HotChocolate GraphQL 服务器添加传播,但根本无法让它工作。

我已经在我的

ConfigureServices services.AddHeaderPropagation(o => o.Headers.Add("Authorization"));

中配置了传播

我已将其添加到我的

httpClient: services.AddHttpClient(AssumptionManagement, c => c.BaseAddress = new Uri("http://localhost:19801")).AddHeaderPropagation();

我已将其添加到我的配置方法中:

app.UseHeaderPropagation();

尽管如此,当我在调试中运行应用程序时,它仍然给出以下错误:

An unhandled exception of type System.InvalidOperationException occurred in System.Private.CoreLib.dll: The HeaderPropagationValues.Headers property has not been initialized. 

通过在

app.UseHeaderPropagation()
方法中添加
Configure(...)
来注册标头传播中间件。标头传播只能在 HTTP 请求的上下文中使用。'

我只是没有看到这里的东西还是我做错了什么?

c# .net-core request-headers hotchocolate
1个回答
0
投票

据我了解,您正在尝试从身份验证中间件拨打电话?在这种情况下,请确保在依赖标头传播的中间件之前调用

app.UseHeaderPropagation()

© www.soinside.com 2019 - 2024. All rights reserved.