Open Closed

Send Custome Http Header #3811


User avatar
0
m.aldayem@cashin.sa created

Project Description: Two Microservice: A, B every Microservice have Background Service: A Background worker, B Background worker

**Issue: ** Add Custome Header when Call A Service From B Background worker I'm using dynamic proxy, and the header is changeable depends on Business so I can't but it in app settings

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v6.
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes / no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"
Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

1 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    You can add a custom message handler

    public override void PreConfigureServices(ServiceConfigurationContext context)
    {
        PreConfigure<AbpHttpClientBuilderOptions>(options =>
        {
            options.ProxyClientBuildActions.Add((s, builder) =>
            {
                builder.AddHttpMessageHandler<MyMessageHandler>();
            });
        });
    }
    
    public class MyMessageHandler : DelegatingHandler, ITransientDependency
    {
        protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            request.Headers.Add(....);
            return base.SendAsync(request, cancellationToken);
        }
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.