code4it-dev / blog-comments

https://www.code4it.dev/
1 stars 0 forks source link

blog/propagate-httpheader-and-correlation-id #33

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

How to propagate HTTP Headers (and Correlation IDs) using HttpClients in C# - Code4IT

Propagating HTTP Headers can be useful, especially when dealing with Correlation IDs. It's time to customize our HttpClients!

https://www.code4it.dev/blog/propagate-httpheader-and-correlation-id

mehdihadeli commented 1 year ago

Hey, Thanks for in detail explanation, Microsoft has a nugget package for handling header propagation Microsoft.AspNetCore.HeaderPropagation It is easier to use.

bellons91 commented 1 year ago

Good point! I'll update the article. Thanks for pointing it out

mehdihadeli commented 1 year ago

@bellons91 Great, Here is a good blog about that. You can also create a new blog post as a new approach for handling this :)

abhilipsan-Hexaware commented 1 year ago

Without Adding line "builder.Services.AddHttpClient("items") .AddHeaderPropagation(options => options.HeaderNames.Add("my-correlation-id"));" headers are not getting propagated..would u be able to explain why?

bellons91 commented 1 year ago

Actually, no.

I found out that if you don't specify the HttpClient's name it doesn't work. But I still haven't figured out why.