CasCap.Common.AspNetCore
4.12.7
Prefix Reserved
dotnet add package CasCap.Common.AspNetCore --version 4.12.7
NuGet\Install-Package CasCap.Common.AspNetCore -Version 4.12.7
<PackageReference Include="CasCap.Common.AspNetCore" Version="4.12.7" />
<PackageVersion Include="CasCap.Common.AspNetCore" Version="4.12.7" />
<PackageReference Include="CasCap.Common.AspNetCore" />
paket add CasCap.Common.AspNetCore --version 4.12.7
#r "nuget: CasCap.Common.AspNetCore, 4.12.7"
#:package CasCap.Common.AspNetCore@4.12.7
#addin nuget:?package=CasCap.Common.AspNetCore&version=4.12.7
#tool nuget:?package=CasCap.Common.AspNetCore&version=4.12.7
CasCap.Common.AspNetCore
ASP.NET Core helpers for the CasCap feature-flag system — feature-gated controller discovery.
Installation
dotnet add package CasCap.Common.AspNetCore
Purpose
In a modular monolith the whole controller surface compiles into one process, but each deployment (pod/host) typically enables only a subset of features (see CasCap.Common.Services / FeatureFlagConfig.EnabledFeatures) and registers only that subset's services. Without gating, every controllers-enabled host maps every controller and returns HTTP 500 when a controller's feature-scoped dependency is not registered — and advertises endpoints in Swagger it cannot actually serve.
Mark a controller with [FeatureController(...)] and call AddFeatureGatedControllers(enabledFeatures) so the controller is only routed (and shown in OpenAPI/Swagger) on hosts where one of its features is enabled. Unmarked controllers are always available (their dependencies must be registered on every host that maps controllers).
This is the single-assembly (type-level) equivalent of gating controllers by
ApplicationPartat the assembly level. Prefer assembly-level gating (AddApplicationPartper enabled feature) when each feature's controllers live in their own assembly, since that also avoids loading off-feature assemblies.
Target frameworks: net8.0, net9.0, net10.0
Usage
// Controller — only mapped where the PafGen feature is enabled:
[ApiController]
[FeatureController(FeatureNames.PafGen)]
[Route("api/v{version:apiVersion}/paf/srzone")]
public sealed class SrZoneController(IPafPlotCollectionSource source) : ControllerBase { /* ... */ }
// Composition root:
builder.Services.AddControllers()
.AddFeatureGatedControllers(enabledFeatures); // same set passed to AddFeatureFlagService(...)
Types
| Type | Description |
|---|---|
FeatureControllerAttribute |
Marks a controller with the feature name(s) that must be enabled for it to be discovered. Unmarked = always available |
FeatureGatedControllerFeatureProvider |
IApplicationFeatureProvider<ControllerFeature> that prunes marked controllers whose feature is not enabled on the host |
Extensions
| Extension | Description |
|---|---|
MvcBuilderExtensions.AddFeatureGatedControllers() |
Adds the FeatureGatedControllerFeatureProvider to the MVC application-part manager for the supplied enabled-feature set |
Dependencies
Framework References
| Reference | Purpose |
|---|---|
Microsoft.AspNetCore.App |
ASP.NET Core MVC application-part / controller-feature types (IApplicationFeatureProvider<ControllerFeature>, IMvcBuilder) |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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 is compatible. 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 is compatible. 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. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.