Integrate FeatureFlags.app into your .NET application in minutes.

Prerequisites

  • .NET 10.0 or later.
  • An API key (create one in the FeatureFlags web UI).

Step 1: Install the Client Package

Add the Acmi.FeatureFlags.Client NuGet package to your project:

dotnet add package Acmi.FeatureFlags.Client

Or add it directly to your .csproj file:

<PackageReference Include="Acmi.FeatureFlags.Client" Version="x.y.z" />

Step 2: Configure the Client

Add the FeatureFlags configuration to your appsettings.json:

{
  "FeatureFlags": {
    "ApiBaseEndpoint": "https://featureflags.app/api/",
    "ApiKey": "[your-api-key]",
    "CacheExpirationInMinutes": 15
  }
}

Configuration Options

ApiBaseEndpoint
The base URL of the FeatureFlags.app API. Must end with /api/ (including the trailing slash).
ApiKey
Your API key created in the FeatureFlags.app web UI. Store this securely using user secrets or environment variables—never commit it to source control.
CacheExpirationInMinutes
How long feature flag definitions are cached in memory. Default is 15 minutes. Balance between performance and flag update responsiveness.

Security Best Practice

For local development, use dotnet user-secrets to store your API key:

dotnet user-secrets set "FeatureFlags:ApiKey" "your-api-key-here"

For production, use environment variables or your cloud provider's secrets management service.

Step 3: Register the Services

In your Program.cs, add the FeatureFlags services using the extension method:

using Acmi.FeatureFlags.Client;

var builder = WebApplication.CreateBuilder(args);

// Add FeatureFlags services
builder.AddFeatureFlags();

// ... rest of your configuration

var app = builder.Build();
await app.RunAsync();

That's it! The extension method registers all necessary services including the client, feature definition provider, and Microsoft's feature management services.

Step 4: Use Feature Flags

Once configured, you can use feature flags throughout your application using Microsoft's IFeatureManager.

In Controllers

public class MyController : Controller
{
    private readonly IFeatureManager _manager;

    public MyController(IFeatureManager featureManager)
    {
        _manager = featureManager;
    }

    public async Task<IActionResult> Index()
    {
        if (await _manager.IsEnabledAsync("IndexFeature"))
        {
            // New feature code
        }
        else
        {
            // Legacy code
        }

        return View();
    }

    [FeatureGate("NewIndexFeature")]
    public async Task<IActionResult> NewIndex()
    {
        return View();
    }
}

In Views

@inject IFeatureManager Manager

<h1>My Page</h1>

@if (await Manager.IsEnabledAsync("NewFeature"))
{
    <div>
        <p>This is the new feature!</p>
    </div>
}
else
{
    <div>
        <p>This is the legacy feature.</p>
    </div>
}

Using the Feature Tag Helper

Microsoft provides a tag helper for cleaner view syntax:

@addTagHelper *, Microsoft.FeatureManagement.AspNetCore

<feature name="NewFeature">
    <p>This content shows when NewFeature is enabled.</p>
</feature>

Step 5: Create Feature Flags

  1. Log in to FeatureFlags.app.
  2. Navigate to the Feature Flags page.
  3. Click "Create New" and give your flag a meaningful name (e.g., "NewFeature").
  4. Toggle the enabled state as needed.
  5. Configure optional filters for advanced scenarios (rollout percentage, user targeting, time windows).

Changes propagate to your application after the cache expires (based on your CacheExpirationInMinutes setting).

Advanced Features

Rollout Percentage

Gradually roll out features to a percentage of users using a percentage filter that will assign users consistently.

User Targeting

Enable features for specific users - use User.Identity.Name for matching users.

Time Windows

Schedule features to enable or disable at specific times, including recurrence.

Custom Filters

Implement your own more complex filters using JSON.

Additional Resources