Eigenverft.WebLib.CanonicalHostRedirect
1.0.0.6-g3f72d1412c
See the version list below for details.
dotnet add package Eigenverft.WebLib.CanonicalHostRedirect --version 1.0.0.6-g3f72d1412c
NuGet\Install-Package Eigenverft.WebLib.CanonicalHostRedirect -Version 1.0.0.6-g3f72d1412c
<PackageReference Include="Eigenverft.WebLib.CanonicalHostRedirect" Version="1.0.0.6-g3f72d1412c" />
<PackageVersion Include="Eigenverft.WebLib.CanonicalHostRedirect" Version="1.0.0.6-g3f72d1412c" />
<PackageReference Include="Eigenverft.WebLib.CanonicalHostRedirect" />
paket add Eigenverft.WebLib.CanonicalHostRedirect --version 1.0.0.6-g3f72d1412c
#r "nuget: Eigenverft.WebLib.CanonicalHostRedirect, 1.0.0.6-g3f72d1412c"
#:package Eigenverft.WebLib.CanonicalHostRedirect@1.0.0.6-g3f72d1412c
#addin nuget:?package=Eigenverft.WebLib.CanonicalHostRedirect&version=1.0.0.6-g3f72d1412c&prerelease
#tool nuget:?package=Eigenverft.WebLib.CanonicalHostRedirect&version=1.0.0.6-g3f72d1412c&prerelease
Eigenverft.WebLib.CanonicalHostRedirect
A small ASP.NET Core middleware that combines canonical host and HTTPS normalization in one permanent redirect.
✨ At a glance
| Capability | What it does |
|---|---|
| AddCanonicalHostRedirect / UseCanonicalHostRedirect | Register configuration and add the redirect middleware. |
| CanonicalHostMode | Choose the apex or www form for the primary host and aliases. |
| Dependency | Uses Eigenverft.WebLib.Middleware.Primitives for isolated use-site options. |
📦 Installation
dotnet add package Eigenverft.WebLib.CanonicalHostRedirect
🚀 Quick start
Canonicalize host and scheme
using Eigenverft.WebLib.CanonicalHostRedirect;
using Microsoft.AspNetCore.Builder;
builder.Services.AddCanonicalHostRedirect(options =>
options.PrimaryApexHost = "example.com");
WebApplication app = builder.Build();
app.UseCanonicalHostRedirect();
app.Run();
Package behavior
The normal defaults canonicalize the primary host group to www, require HTTPS, return 308 Permanent Redirect, and use implicit HTTPS port 443. Set RedirectFromHosts for additional host aliases or Canonicalization = CanonicalHostMode.ToApex to use the apex host. HttpsTargetPort may select one HTTPS port for every redirect; null and 443 omit the port. Incoming HTTP ports are never copied into the HTTPS target.
The redirect preserves PathBase, path, and query and combines host and scheme changes into one hop. A host that is not the primary host or a listed alias keeps its host name and is still redirected to HTTPS. Already-canonical HTTPS requests continue through the pipeline.
AddCanonicalHostRedirect() binds the CanonicalHostRedirect configuration section. The overload with an Action applies code configuration after binding. The UseCanonicalHostRedirect(Action<CanonicalHostRedirectOptions>) overload applies a local override to only that middleware use; configuration reload rebuilds the baseline and reapplies that override.
Place ASP.NET Core UseForwardedHeaders() before this middleware when a trusted reverse proxy supplies the client-facing host or scheme. PrimaryApexHost and RedirectFromHosts must not contain ports; configure HttpsTargetPort instead. Configured target ports must be between 1 and 65535.
🎯 Target frameworks
Targets .NET 8 and .NET 10. A .NET 9 application can consume the compatible net8.0 asset.
🔗 Project links
📄 License
Licensed under the MIT License by Eigenverft.
| 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 was computed. 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
- Eigenverft.WebLib.Middleware.Primitives (>= 1.0.0.5-g3f72d1412c)
-
net8.0
- Eigenverft.WebLib.Middleware.Primitives (>= 1.0.0.5-g3f72d1412c)
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0.6-g40a2f17cdc | 0 | 9/28/2026 |
| 1.0.0.6-g3f72d1412c | 0 | 9/29/2026 |
| 1.0.0.3-gbfce1c5596 | 0 | 9/28/2026 |
| 1.0.0.3-g8afd56e9dc | 0 | 9/12/2026 |
Initial capability package extracted from Eigenverft.WebLib.Infrastructure.
- ASP.NET Core middleware for redirecting requests to a configured canonical host with configurable redirect behavior.
- Public namespaces and behavior remain compatible with the original Infrastructure implementation.