ZRouting - LayerZero.Tools.Routing (.NET 8+ Routing manager)

ZRouting is a convention-based routing extension for ASP.NET Core (.NET) designed to standardize URL structures using namespace-driven tokens.

It enables modular applications to derive route segments directly from controller namespace structure, reducing repetitive configuration while enforcing architectural consistency.

ZRouting is particularly suited for:

It promotes predictable routing patterns without requiring attribute duplication or extensive per-controller configuration.


1. Overview

ZRouting extends ASP.NET Core routing by introducing configurable route tokens that map to controller namespace segments.

Instead of manually defining routes or repeating attributes across controllers, route values can be inferred from structural conventions defined once during startup.

This approach ensures:


2. Features Overview

2.1 Convention-Based Route Composition

ZRouting introduces configurable route tokens that are resolved from namespace segments and injected into a route template.

Example configuration:

builder.AddZRouting(cfg =>
{
    cfg.Tokens = new List<ZRouteToken>
    {
        new ZRouteToken { NameSpaceIndex = 5, DefaultValue = "0_0", Name = "version" },
        new ZRouteToken { NameSpaceIndex = 6, DefaultValue = "unknown", Name = "feature" },
        new ZRouteToken { NameSpaceIndex = 4, DefaultValue = "unknown", Name = "area" }
    };

    cfg.RouteTemplate = "[area]/v[version]/[feature]/[controller]/[action]";
});

The above configuration is only a sample. Token names, namespace indexes, and route templates are fully customizable.


2.2 Flexible Token System

Each token consists of:

This enables:


2.3 Startup-Time Resolution

Route token resolution occurs during application startup.

This ensures:


3. Component Index (Feature Modules)

ZRouting integrates naturally with feature-oriented module structures.

3.1 Example Namespace Structure

Company.Product.Area.V1_0.Feature.Controllers

With appropriate token configuration, this may map to:

/{area}/v{version}/{feature}/{controller}/{action}

The mapping behavior is entirely driven by configured tokens.


4. Design Goals