StrongOf.AspNetCore
2.0.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
Requires NuGet 2.12 or higher.
dotnet add package StrongOf.AspNetCore --version 2.0.2
NuGet\Install-Package StrongOf.AspNetCore -Version 2.0.2
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="StrongOf.AspNetCore" Version="2.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StrongOf.AspNetCore" Version="2.0.2" />
<PackageReference Include="StrongOf.AspNetCore" />
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 StrongOf.AspNetCore --version 2.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: StrongOf.AspNetCore, 2.0.2"
#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 StrongOf.AspNetCore@2.0.2
#: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=StrongOf.AspNetCore&version=2.0.2
#tool nuget:?package=StrongOf.AspNetCore&version=2.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
StrongOf.AspNetCore
ASP.NET Core model binders for StrongOf types. Enables route values, query strings, and form fields to be automatically parsed into strong types.
Available Binders
| Binder | For |
|---|---|
StrongGuidBinder<T> |
StrongGuid<T> types |
StrongStringBinder<T> |
StrongString<T> types |
StrongInt32Binder<T> |
StrongInt32<T> types |
StrongInt64Binder<T> |
StrongInt64<T> types |
StrongDecimalBinder<T> |
StrongDecimal<T> types |
Setup
Register a custom IModelBinderProvider in your ASP.NET Core startup:
// Program.cs
builder.Services.AddControllers(options =>
options.ModelBinderProviders.Insert(0, new MyBinderProvider()));
// MyBinderProvider.cs
public sealed class MyBinderProvider : IModelBinderProvider
{
private static readonly IReadOnlyDictionary<Type, Type> s_binders =
new Dictionary<Type, Type>
{
{ typeof(UserId), typeof(StrongGuidBinder<UserId>) },
{ typeof(EmailAddress), typeof(StrongStringBinder<EmailAddress>) },
};
public IModelBinder? GetBinder(ModelBinderProviderContext context)
{
if (s_binders.TryGetValue(context.Metadata.ModelType, out Type? binderType))
{
return new BinderTypeModelBinder(binderType);
}
return null;
}
}
Custom Binders
Extend StrongOfBinder to add custom parsing logic:
public sealed class MyUserIdBinder : StrongOfBinder
{
public override bool TryHandle(string value, out ModelBindingResult result)
{
if (StrongGuid<UserId>.TryParse(value, out UserId? id))
{
result = ModelBindingResult.Success(id);
return true;
}
result = ModelBindingResult.Failed();
return false;
}
}
Installation
dotnet add package StrongOf.AspNetCore
GitHub
| 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. net11.0 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 |
|---|---|---|
| 2.1.8 | 85 | 2/28/2026 |
| 2.0.2 | 111 | 2/20/2026 |
| 1.2.15 | 642 | 4/26/2025 |
| 1.2.8 | 249 | 4/9/2025 |
| 1.2.7 | 1,950 | 2/18/2025 |
| 1.2.7-ga639164e54 | 137 | 2/18/2025 |
| 1.2.4 | 1,092 | 11/28/2024 |
| 1.2.4-g0988d2c02d | 152 | 11/28/2024 |
| 1.2.2 | 804 | 11/15/2024 |
| 1.2.2-gbc3f3048e7 | 144 | 11/15/2024 |
| 1.1.4 | 199 | 11/12/2024 |
| 1.1.4-g6e854f6d6d | 161 | 11/12/2024 |
| 1.1.2 | 284 | 11/5/2024 |
| 1.1.2-g0a1a51912f | 137 | 11/5/2024 |
| 0.1.71 | 301 | 11/3/2024 |
| 0.1.71-g40ec49b665 | 160 | 11/3/2024 |
| 0.1.65 | 366 | 6/2/2024 |
| 0.1.65-g31f777a546 | 198 | 6/2/2024 |
| 0.1.63 | 213 | 6/1/2024 |
| 0.1.63-g3ca390c476 | 161 | 6/1/2024 |
Loading failed