Skip to content

InvalidOperationException: The HeaderPropagationValues.Headers property has not been initialized #5

@dmitry-pavlov

Description

@dmitry-pavlov

Hi @alefranz ,

I am getting the exception below. Please let me know why. Thanks!

System.InvalidOperationException: The HeaderPropagationValues.Headers property has not been initialized. Register the header propagation middleware by adding 'app.UseHeaderPropagation() in the 'Configure(...)' method.
   at Microsoft.AspNetCore.HeaderPropagation.HeaderPropagationMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)

ConfigureServices:

services.AddHttpClient<IMyServiceClient, MyServiceClient>((provider, client) =>
{
    var serviceSettings = _settings.ExternalServices.MyClient;

    client.BaseAddress = new Uri(serviceSettings.BaseAddress);

}).AddHeaderPropagation();

Configure:

app.UseHeaderPropagation();
app.UseAuthentication();
app.UseMvc();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions