Quickstart by stack

.NET Quickstart

Install the .NET SDK from NuGet, evaluate a flag with context, and register it with ASP.NET Core dependency injection and middleware.

Prerequisites

  • .NET 8.0 or later.
  • A server key (prefixed srv_) stored in environment configuration and not committed to source.
  • A flag key you can test in a non-production environment.
Install bash

dotnet add package Zenmanage
Initialize and evaluate csharp

using Zenmanage;

var zenmanage = new Zenmanage.Zenmanage(
    ConfigBuilder.Create()
        .WithEnvironmentToken(Environment.GetEnvironmentVariable("ZENMANAGE_SERVER_KEY"))
        .Build());

var flag = await zenmanage.Flags().SingleAsync("new-dashboard");

if (flag.IsEnabled())
{
    Console.WriteLine("Render the new dashboard");
}
ASP.NET Core registration csharp

using Zenmanage;
using Zenmanage.AspNetCore;
using Zenmanage.Contexting;

builder.Services.AddZenmanage(options =>
    options
        .WithEnvironmentToken(builder.Configuration["Zenmanage:EnvironmentToken"])
        .WithCacheBackend(CacheBackend.Memory));

var app = builder.Build();

// Add after authentication so HttpContext.User is populated.
app.UseZenmanage(ctx => Context.Single("user", ctx.User.Identity?.Name ?? "anonymous"));

app.MapGet("/feature-check", async (IFlagManager flags) =>
{
    var flag = await flags.SingleAsync("new-checkout-flow");
    return Results.Ok(new { isEnabled = flag.IsEnabled() });
});
Error-handling pattern csharp

using Zenmanage.Exceptions;

try
{
    var timeout = (await zenmanage.Flags().SingleAsync("api-timeout-ms")).AsNumber();
}
catch (EvaluationException ex)
{
    Console.WriteLine($"flag not found: {ex.Message}");
}
catch (FetchRulesException ex)
{
    Console.WriteLine($"failed to fetch rules: {ex.Message}");
}

// Or pass an inline default to avoid the exception entirely.
var flag = await zenmanage.Flags().SingleAsync("api-timeout-ms", 5000);

Server and client keys

The .NET SDK accepts both server keys (srv_) and client keys (cli_) — ConfigBuilder validates for a server runtime by default, so call WithRuntimeEnvironment(RuntimeEnvironment.Client) explicitly when using a client key. Mobile keys are not supported; use the iOS or Android SDK for those runtimes.

ASP.NET Core integration

The Zenmanage.AspNetCore package adds dependency-injection registration and request-scoped middleware, so a request-bound IFlagManager is ready to inject into any controller or minimal API endpoint.

Next step

Take the next integration step in your own stack.

Start with the quickstart that matches your runtime, then return to the reference pages when you need exact request and payload details.

Language and framework names and logos shown above are trademarks or registered trademarks of their respective owners. Their use here is for identification purposes only and does not imply endorsement of, or affiliation with, Zenmanage.