Argon.Extensions.Hosting 8.4.0

Argon.Extensions.Hosting

Middlewares and extensions for ASP.NET Core applications.

📦 Installation

dotnet add package Argon.Extensions.Hosting

✨ Features

  • StaticPathBaseMiddleware : Middleware to handle a static path base
  • Extensions to easily configure middlewares

🚀 Usage

StaticPathBaseMiddleware

This middleware ensures that all requests start with a specified path base. Requests that don't match the path base will receive a 404 response.

using Argon.Extensions.Hosting.Middlewares;

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

// Use a static path base
app.UseStaticPathBase("/api");

app.MapControllers();
app.Run();

What it does

  • Validates that incoming requests start with the specified path base
  • Adds the path base to HttpContext.Request.PathBase
  • Returns 404 for requests that don't match the path base
  • Properly strips the path base from the remaining path

Example

With app.UseStaticPathBase("/api"):

  • /api/users → PathBase: /api, Path: /users
  • /api/products/123 → PathBase: /api, Path: /products/123
  • /users → 404 Not Found

Configuration

var app = builder.Build();

// Configure the static path base
app.UseStaticPathBase("/api/v1");

// Your other middleware
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();

app.Run();

📝 API Reference

Extensions

UseStaticPathBase

public static IApplicationBuilder UseStaticPathBase(
    this IApplicationBuilder app, 
    PathString pathBase)

Adds the StaticPathBaseMiddleware to the application pipeline.

Parameters:

  • app : The application builder
  • pathBase : The path base to extract (must not be empty)

Returns: The application builder for method chaining

Exceptions:

  • ArgumentNullException : If app is null
  • ArgumentException : If pathBase is null or empty

No packages depend on Argon.Extensions.Hosting.

Version Downloads Last updated
8.5.0 16 11/30/2025
8.4.0 29 11/17/2025
8.3.0 10 07/17/2025
8.2.1 244 07/08/2025
8.2.0 8 07/08/2025
8.1.1 6 07/08/2025
8.1.0 6 07/08/2025
8.0.0 7 07/08/2025