Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
ASP.NETCORE use feature flags inside ConfigureServices

I'm using Feature Flags as described here. It works alright, I'm just wondering if the following is really the best way to use them if I want to switch between different service implementations inside ConfigureServices()?

I have the following so far:

using Microsoft.FeatureManagement;

public void ConfigureServices(IServiceCollection services)
{
    services.AddFeatureManagement();

    var sp = services.BuildServiceProvider();
    var featureManager = sp.GetService<IFeatureManager>();

    if (featureManager.IsEnabledAsync("UseServiceB").Result)
    {
        services.AddHostedService<MyServiceB>();
    }
    else
    {
        services.AddHostedService<MyServiceA>();
    }
}

Especially since IFeatureManager only provides an async method to check for a feature, this doesn't feel quite right?!

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!