This site provides a machine-readable index at /llms.txt.

Skip to main content Skip to navigation

LocaleDetectionMiddleware Pennington.Localization

Middleware that detects the locale from the URL path prefix, populates LocaleContext, and rewrites the request path to strip the locale segment. This allows Razor components to use a single @page directive without duplicating routes per locale.

Constructors

.ctor

#
public LocaleDetectionMiddleware(RequestDelegate next, LocalizationOptions localization);

Creates the middleware.

Parameters

next RequestDelegate
localization LocalizationOptions

Methods

Invoke

#
public Task Invoke(HttpContext context);

Processes the request: detects the locale, populates LocaleContext, and strips the locale prefix from the request path.

Parameters

context HttpContext

Returns

Task

Pennington.Localization.LocaleDetectionMiddleware

namespace Pennington.Localization;

/// Middleware that detects the locale from the URL path prefix, populates LocaleContext, and rewrites the request path to strip the locale segment. This allows Razor components to use a single @page directive without duplicating routes per locale.
public class LocaleDetectionMiddleware
{
    /// Creates the middleware.
    
public LocaleDetectionMiddleware(RequestDelegate next, LocalizationOptions localization);
/// Processes the request: detects the locale, populates LocaleContext, and strips the locale prefix from the request path.
public Task Invoke(HttpContext context);
}