Table of Contents

Views

Description

The framework extends ASP.NET view discovery to support feature-folder structure — controllers and their views can live in the same folder anywhere in the project.

Features

  • Feature folder support: views are discovered next to their controllers
  • Auto namespace discovery: controller namespaces are automatically registered as view search paths at startup
  • Custom view locations: add extra view paths via FrameworkOptions.ViewLocations
  • Custom expander: pass your own IViewLocationExpander via FrameworkOptions.ViewLocationExpander

Behavior

The framework registers these view search paths automatically:

/{controller}/{view}.cshtml
/{namespaceSegment}/{controller}/{view}.cshtml
/{namespaceSegment}/{controller}/{controller}.cshtml
/{namespaceSegment}/{controller}/Views/{view}.cshtml
/{namespaceSegment}/Views/Shared/{controller}/{view}.cshtml

Namespace segments of discovered controllers are also added as view search paths — so a controller in MyApp.Content.Home namespace automatically registers Content/Home as a valid view root.

Custom locations from FrameworkOptions are appended after the built-in paths — built-in paths always take priority.

Caveats

  • Built-in view paths take priority
  • View namespace discovery runs once on first request — not at startup
  • ApplicationParts must be set in FrameworkOptions if controllers live in external assemblies
  • Custom ViewLocationExpander runs alongside the built-in expander — both are active simultaneously
Tip

Organise your project as feature folders — keep HomeController.cs and Index.cshtml in the same ~/Content/Home/ folder. No configuration needed, the framework discovers them automatically.