Skip to content

ConsoleMVC

ConsoleMVC is a .NET framework that brings the familiar Model-View-Controller pattern from ASP.NET Core MVC to console applications. Rather than building interactive console programmes with tangled input loops and ad-hoc screen rendering, ConsoleMVC lets you structure your application around controllers, actions, and strongly-typed views, the same concepts used in web development, adapted for the terminal.

The framework handles the core event loop for you: it resolves the appropriate controller, invokes the requested action, renders a view, and waits for navigation input before repeating the cycle. You focus on writing controllers that return results and views that present data, while ConsoleMVC takes care of routing, discovery, and lifecycle management.

ConsoleMVC also ships with a Roslyn source generator that compiles .cvw template files (a Razor-like syntax for console views) into strongly-typed C# classes at build time. This means you get compile-time safety for your views without any runtime template parsing overhead.

  • Getting Started: install the framework and create your first console MVC application.
  • Controllers and Forms: actions, navigation, posting forms and model binding.
  • C-View Markup: describe screens with <box>, <text>, <table> and <columns>, reuse markup with <partial>, draw <bar-chart> and <sparkline>, show <markdown>, page long content with <scroll>, style it with themes, and collect input with <input>, <select>, <radio>, <checkbox> and <menu>.
  • Validation: DataAnnotations, ModelState and <errors />.
  • Dependency Injection: register services and receive them in controllers and views (@inject).
  • Async Actions and Middleware: await in actions and run code around every action with app.Use.
  • Areas and Modules: group screens into areas (nav="Admin/Users/Index") and add feature modules from other assemblies.
  • Live Screens: <progress> and <spinner> while an action works, and views that refresh on a timer with @refresh.
  • Configuration Files and Logging: appsettings.json, environment variables, options and ILogger<T>.
  • Builder Options: the builder, themes and live reload.
  • Testing: run the application in tests with ConsoleMVC.Testing, scripted input and snapshots.
  • Native AOT and Trimming: publish a single native executable that starts in milliseconds.
  • Remote Sessions: serve the application to many users at once over Telnet, TLS, SSH or a web terminal.
  • Accessibility: a screen-reader mode and a high-contrast theme that users can turn on.
  • Localisation: resources in views, translated framework messages and validation, and the run's culture.
  • API Reference: auto-generated reference documentation for all public types.