StrEnum.AspNetCore 3.3.1

Prefix Reserved
dotnet add package StrEnum.AspNetCore --version 3.3.1
                    
NuGet\Install-Package StrEnum.AspNetCore -Version 3.3.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="StrEnum.AspNetCore" Version="3.3.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StrEnum.AspNetCore" Version="3.3.1" />
                    
Directory.Packages.props
<PackageReference Include="StrEnum.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 StrEnum.AspNetCore --version 3.3.1
                    
#r "nuget: StrEnum.AspNetCore, 3.3.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 StrEnum.AspNetCore@3.3.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=StrEnum.AspNetCore&version=3.3.1
                    
Install as a Cake Addin
#tool nuget:?package=StrEnum.AspNetCore&version=3.3.1
                    
Install as a Cake Tool

StrEnum.AspNetCore

Lets you use StrEnum string enums with ASP.NET Core.

Supports ASP.NET Core 6 – 10. For ASP.NET Core 5, use v2.0.0.

Installation

Install StrEnum.AspNetCore via the .NET CLI:

dotnet add package StrEnum.AspNetCore

Usage

Registering the binder

If you're using WebApplicationBuilder, call AddStringEnums() in Program.cs:

var builder = WebApplication.CreateBuilder(args);

builder.Services
    .AddControllers()
    .AddStringEnums();

For the ASP.NET Core 3.1–5 IWebHostBuilder, call AddStringEnums() in ConfigureServices in Startup.cs:

public void ConfigureServices(IServiceCollection services)
{
    services
        .AddControllers()
        .AddStringEnums();
}

Defining a string enum and a model

public class Sport : StringEnum<Sport>
{
    public static Sport TrailRunning = Define("TRAIL_RUNNING");
    public static Sport RoadCycling = Define("ROAD_CYCLING");
}

public class Race
{
    public string Name { get; set; }
    public Sport Sport { get; set; }
}

Binding string enums in controllers

Bind from the request body and serialize them back in the response:

[HttpPost]
public ActionResult<Race> BodyPost([FromBody] Race race) // race.Sport is deserialized correctly
{
    return Ok(race); // race.Sport is serialized back
}

Bind from a route parameter:

[HttpGet]
[Route("{sport}")]
public ActionResult<ResponseWithStrEnum> GetFromRoute(Sport sport) { ... }

Bind from a query string parameter:

[HttpGet]
[Route("get")]
public ActionResult<ResponseWithStrEnum> GetFromQuery([FromQuery] Sport sport) { ... }
// `get?sport=trail_running` binds to Sport.TrailRunning

Bind to an array of query string parameters:

[HttpGet]
[Route("get")]
public ActionResult<ResponseWithStrEnum> GetFromQuery([FromQuery] Sport[] sports) { ... }
// `get?sports=trail_running&sports=road_cycling` binds to [Sport.TrailRunning, Sport.RoadCycling]

License

Copyright © 2026 Dmytro Khmara.

StrEnum is licensed under the MIT license.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 is compatible.  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 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. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.3.1 92 4/25/2026
3.3.0 134 2/11/2026
3.2.0 1,243 7/7/2025
3.1.0 1,011 6/11/2023
3.0.0 307 6/11/2023
2.0.0 598 7/30/2022
1.0.0 599 5/19/2022