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
<PackageReference Include="Propel.FeatureFlags.AspNetCore" Version="2.2.1" />
<PackageVersion Include="Propel.FeatureFlags.AspNetCore" Version="2.2.1" />
<PackageReference Include="Propel.FeatureFlags.AspNetCore" />
paket add Propel.FeatureFlags.AspNetCore --version 2.2.1
#r "nuget: Propel.FeatureFlags.AspNetCore, 2.2.1"
#:package Propel.FeatureFlags.AspNetCore@2.2.1
#addin nuget:?package=Propel.FeatureFlags.AspNetCore&version=2.2.1
#tool nuget:?package=Propel.FeatureFlags.AspNetCore&version=2.2.1
Propel.FeatureFlags.AspNetCore
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
HttpContextorControllerBase - 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 evaluatorcontext.IsFeatureFlagEnabledAsync(flag)- Check if a flag is enabledcontext.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 keyDisableMaintenance()- Disable maintenance modeWithMaintenanceResponse(response)- Set custom maintenance responseAddGlobalFlag(key, statusCode, response)- Add a global feature gateExtractTenantIdFrom(extractor)- Custom tenant ID extractionExtractUserIdFrom(extractor)- Custom user ID extractionExtractAttributes(extractor)- Custom attribute extraction
How It Works
- Middleware intercepts requests and extracts context (tenant, user, attributes)
- Global flags are evaluated - if disabled, request is blocked with configured response
- Maintenance mode is checked - if active, returns 503 Service Unavailable
- Evaluator is added to HttpContext.Items for downstream use
- Extensions provide easy access to evaluate flags in controllers and endpoints
Dependencies
- Propel.FeatureFlags
- Microsoft.AspNetCore.Mvc.Core
- Newtonsoft.Json
| Product | Versions 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. |
-
.NETStandard 2.0
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
- Newtonsoft.Json (>= 13.0.4)
- Propel.FeatureFlags (>= 2.2.1)
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 |