Table of Contents

Controllers

Description

The framework extends ASP.NET MVC with routing conventions, smart action selection, and a base API controller with built-in documentation endpoint.

Features

  • Auto-routing: controllers are routed automatically based on class name and namespace — no [Route] attributes needed
  • BaseApiController: base class for all API controllers, adds /docs endpoint listing all actions and their parameters
  • Short route: controllers suffixed with Api get both a full and short route — PokemonApiController resolves as both /api/pokemonapi/ and /api/pokemon/
  • Smart action selection: when multiple actions match a request, the one whose parameters best match the query string wins

Behavior

Routing conventions are applied automatically at startup — controllers inheriting Controller or BaseApiController get routes registered without any attributes.

API routes are prefixed with /api/ and follow [controller]/[action] pattern. Namespace segments beyond the root are included in the path:

MyApp.Api.Admin.UserApiController  →  /api/admin/userapi/  and  /api/admin/user/

Action selection resolves ambiguity when multiple overloads exist — if query string parameters match an action's parameter names, that action wins. If no query string exists, the parameterless action wins.

Caveats

  • Controllers with an explicit [Route] attribute are excluded from auto-routing conventions
  • Controllers with [ApiController] attribute are excluded from auto-routing conventions
Tip

Inherit BaseApiController for all your APIs to get the free /docs endpoint.