Propel.FeatureFlags.AspNetCore 2.2.1

dotnet add package Propel.FeatureFlags.AspNetCore --version 2.2.1
                    
NuGet\Install-Package Propel.FeatureFlags.AspNetCore -Version 2.2.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Propel.FeatureFlags.AspNetCore" Version="2.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Propel.FeatureFlags.AspNetCore" Version="2.2.1" />
                    
Directory.Packages.props
<PackageReference Include="Propel.FeatureFlags.AspNetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Propel.FeatureFlags.AspNetCore --version 2.2.1
                    
#r "nuget: Propel.FeatureFlags.AspNetCore, 2.2.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Propel.FeatureFlags.AspNetCore@2.2.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Propel.FeatureFlags.AspNetCore&version=2.2.1
                    
Install as a Cake Addin
#tool nuget:?package=Propel.FeatureFlags.AspNetCore&version=2.2.1
                    
Install as a Cake Tool

Propel.FeatureFlags.AspNetCore

Build and Test NuGet NuGet Downloads .NET Standard 2.0

ASP.NET Core integration library for Propel Feature Flags, providing middleware, extension methods, and HTTP context integration for feature flag evaluation in web applications.

For detailed documentation and examples, visit the repository readme.

Features

  • Feature Flag Middleware - Global feature gates, maintenance mode, and automatic context extraction
  • HTTP Context Extensions - Evaluate feature flags directly from HttpContext or ControllerBase
  • Context-Aware Evaluation - Automatic extraction of tenant ID, user ID, and custom attributes from HTTP requests
  • Fluent Configuration - Builder pattern for middleware options

Installation

dotnet add package Propel.FeatureFlags.AspNetCore

Quick Start

1. Configure Services

builder.Services 
    .ConfigureFeatureFlags(config => 
        { 
            config.RegisterFlagsWithContainer = true; 
            config.EnableFlagFactory = true;
         }) 
    .AddPostgreSqlFeatureFlags(connectionString) //database provider required
    .AddRedisCache(redisConnection)              //cache provider is optional;

2. Add Middleware

Basic usage, maintenance mode, and global feature gates examples:

// Basic usage 
app.UseFeatureFlags();

// With maintenance mode 
app.UseFeatureFlags(options => 
    { 
        options
        .EnableMaintenanceMode("api-maintenance") 
        .WithMaintenanceResponse(new { message = "API is temporarily down for maintenance", estimatedDuration = "30 minutes" }); 
    });
// With global feature gates 
app.UseFeatureFlags(options => 
    { 
        options.AddGlobalFlag("api-v2-enabled", 410, new { error = "API v2 is no longer available" }); 
    });

3. Evaluate Flags in Endpoints

Minimal API:

app.MapGet("/admin/sensitive-operation", 
    async (HttpContext context) => 
        { 
            var flag = new AdminPanelEnabledFeatureFlag();
            if (await context.IsFeatureFlagEnabledAsync(flag))
            {
                return Results.Ok("Operation completed");
            }

            return Results.NotFound();
        });

Controller:

public class AdminController : ControllerBase 
{ 
    [HttpGet("dashboard")] 
    public async Task<IActionResult> GetDashboard() 
    { 
        var evaluator = this.FeatureFlags(); 
        var flag = new AdminDashboardFlag();
        if (await evaluator.IsEnabledAsync(flag))
        {
            return Ok(dashboardData);
        }
    
        return NotFound();
    }
}

Advanced Configuration

Custom Context Extraction

app.UseFeatureFlags(options => 
    { 
        // Custom user ID extraction 
        options.ExtractUserIdFrom(context => 
            context.User.FindFirst("sub")?.Value ?? context.Request.Headers["X-API-Key"].FirstOrDefault() );

        // Custom tenant ID extraction
        options.ExtractTenantIdFrom(context =>
            context.Request.Headers["X-Tenant-ID"].FirstOrDefault()
        );

        // Custom attributes for targeting rules
        options.ExtractAttributes(context =>
        {
            var attributes = new Dictionary<string, object>();
    
            if (context.Request.Headers.TryGetValue("Role", out var role))
                attributes["role"] = role.ToString();
        
            if (context.Request.Headers.TryGetValue("Country", out var country))
                attributes["country"] = country.ToString();
        
            return attributes;
        });
});

Complete Example

app.UseFeatureFlags(options => 
    { 
        // Enable maintenance mode 
        options.EnableMaintenanceMode("api-maintenance") 
                .WithMaintenanceResponse(new { message = "Service temporarily unavailable", contact = "support@company.com" });
        
        // Add global feature gates
        options.AddGlobalFlag("beta-features-enabled", 403, new
        {
            error = "Beta features not available for your account"
        });

        // Custom context extraction
        options.ExtractUserIdFrom(context =>
            context.User.FindFirst("sub")?.Value ??
            context.Request.Headers["User-Id"].FirstOrDefault()
        );

        options.ExtractAttributes(context =>
        {
            var attributes = new Dictionary<string, object>();
    
            if (context.Request.Headers.TryGetValue("Role", out var role))
                attributes["role"] = role.ToString();
        
            if (context.Request.Headers.TryGetValue("Department", out var dept))
                attributes["department"] = dept.ToString();
        
            return attributes;
        });
});

API Reference

Extension Methods

HttpContext Extensions
  • context.FeatureFlags() - Get the feature flag evaluator
  • context.IsFeatureFlagEnabledAsync(flag) - Check if a flag is enabled
  • context.GetFeatureFlagVariationAsync<T>(flag, defaultValue) - Get flag variation value
Controller Extensions
  • this.FeatureFlags() - Get the feature flag evaluator from controller

Middleware Options Builder

  • EnableMaintenanceMode(flagKey) - Enable maintenance mode with custom flag key
  • DisableMaintenance() - Disable maintenance mode
  • WithMaintenanceResponse(response) - Set custom maintenance response
  • AddGlobalFlag(key, statusCode, response) - Add a global feature gate
  • ExtractTenantIdFrom(extractor) - Custom tenant ID extraction
  • ExtractUserIdFrom(extractor) - Custom user ID extraction
  • ExtractAttributes(extractor) - Custom attribute extraction

How It Works

  1. Middleware intercepts requests and extracts context (tenant, user, attributes)
  2. Global flags are evaluated - if disabled, request is blocked with configured response
  3. Maintenance mode is checked - if active, returns 503 Service Unavailable
  4. Evaluator is added to HttpContext.Items for downstream use
  5. Extensions provide easy access to evaluate flags in controllers and endpoints

Dependencies

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Propel.FeatureFlags.AspNetCore:

Package Downloads
Propel.FeatureFlags.Attributes

Aspect-Oriented Programming (AOP) integration for Propel Feature Flags using Castle DynamicProxy. Enables declarative feature flag evaluation through the [FeatureFlagged] attribute with support for both synchronous and asynchronous methods, fallback method execution, and automatic proxy generation for runtime interception.

Propel.FeatureFlags.PostgreSql

PostgreSQL storage provider for Propel Feature Flags using Npgsql. Handles database operations and schema migraions for feature flag data with automatic schema creation and JSON storage for targeting rules and configurations.

Propel.FeatureFlags.SqlServer

SqlServer storage provider for Propel Feature Flags using SqlClient. Handles database operations and schema migrations for feature flag data with automatic schema creation and JSON storage for targeting rules and configurations.

Propel.FeatureFlags.DependencyInjection.Extensions

Core feature flag models and evaluation engine for .NET applications

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.1 250 10/20/2025
2.2.1-beta.1.2 116 10/19/2025
2.1.1-beta.1.2 43 10/18/2025
2.1.0-beta.1.2 127 10/16/2025
2.0.0-beta.1.2 127 10/14/2025
1.0.1-beta.1 124 10/7/2025
1.0.0-beta.1 122 10/7/2025