Modrich.Web 0.1.0

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

Modrich.Web

Host-side web helpers for Modrich on .NET 10. Sits between the Tier 1 abstractions and the concrete host. Modules do not reference this package.

What's in the box

  • GlobalExceptionHandlingMiddleware — catches unhandled exceptions and writes a JSON envelope ({ StatusCode, Message }). Maps common exception types:
    • ArgumentException400
    • KeyNotFoundException404
    • UnauthorizedAccessException401
    • anything else → 500 with a generic message
  • CultureEndpoints.MapCultureEndpoints(endpoints) — registers GET /Culture/Set?culture=fr&redirectUri=/ which writes the ASP.NET Core localization cookie and local-redirects back.

Install

dotnet add package Modrich.Web

Usage — JSON exception middleware on /api only

The middleware emits JSON, so wire it on the API branch only — HTML routes should keep the standard exception handler so Blazor can render its own error page.

using Modrich.Web.Middleware;

var app = builder.Build();

app.UseExceptionHandler("/error");          // HTML routes
app.UseHsts();

app.MapWhen(ctx => ctx.Request.Path.StartsWithSegments("/api"), branch =>
{
    branch.UseMiddleware<GlobalExceptionHandlingMiddleware>();
});

app.Run();

Response shape on failure:

{ "StatusCode": 404, "Message": "Order 42 not found." }

Usage — culture switcher

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Options;
using Modrich.Web.Endpoints;

var supported = new[] { "en", "fr", "de" };
builder.Services.Configure<RequestLocalizationOptions>(o =>
{
    o.SetDefaultCulture("en")
     .AddSupportedCultures(supported)
     .AddSupportedUICultures(supported);
});

var app = builder.Build();

app.UseRequestLocalization(app.Services.GetRequiredService<IOptions<RequestLocalizationOptions>>().Value);

app.MapCultureEndpoints();   // GET /Culture/Set?culture=fr&redirectUri=/

app.Run();

A language switcher link:

<a href="/Culture/Set?culture=fr&redirectUri=@Uri.EscapeDataString(currentPath)">Français</a>

The endpoint writes a one-year IsEssential = true, SameSite = Lax cookie via CookieRequestCultureProvider.MakeCookieValue(...), then issues a LocalRedirect back to redirectUri (defaults to /).

  • Modrich.Abstractions / Modrich.Modularity — the host you're configuring most likely uses these.

Versioning

Strict semver. EnablePackageValidation is on.

License

MIT.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Modrich.Web:

Package Downloads
Modrich.Sdk.Web

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 103 5/23/2026
0.0.1 93 5/23/2026