IronLoon.AspNetCore.PathBaseNormalizer 1.0.0

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

AspNetCore.PathBaseNormalizer

ASP.NET Core middleware that normalizes PathBase casing with a 301 redirect.

When ASP.NET Core apps run behind IIS as virtual applications, users can type the URL in any casing (e.g. /myapp instead of /MyApp). IIS matches case-insensitively and passes the request through with the user's original casing in Request.PathBase. This causes problems because:

  • OIDC redirect URIs registered in Azure AD / Entra ID are case-sensitive
  • Cookie paths are case-sensitive in browsers
  • Auth cookies set under /myapp won't be sent for requests to /MyApp

This middleware fixes the issue by redirecting to the canonical casing before any auth middleware runs.

Installation

dotnet add package IronLoon.AspNetCore.PathBaseNormalizer

Usage

Register the middleware before authentication, authorization, and static file middleware:

var app = builder.Build();

// Must be first middleware — redirects before auth cookies are evaluated
app.UsePathBaseNormalization("/MyApp");

app.UseAuthentication();
app.UseAuthorization();
// ...

If the user requests https://host/myapp/page, they get a 301 Moved Permanently redirect to https://host/MyApp/page.

Requests with the correct casing pass through with zero overhead (a single ordinal string comparison).

Multi-segment paths

Works with nested virtual app paths:

app.UsePathBaseNormalization("/Org/MyApp");

How it works

  1. Compares Request.PathBase against the canonical value (case-insensitive)
  2. If it matches but the casing differs, issues a 301 Moved Permanently redirect with the corrected PathBase
  3. If it matches exactly or doesn't match at all, passes through to the next middleware

Requirements

  • .NET 8.0 or .NET 10.0
  • ASP.NET Core

License

MIT

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

    • No dependencies.
  • net8.0

    • No dependencies.

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
1.0.0 145 4/7/2026