Controllers
Use a controller when a page needs more than a view: query parameters, a model built from several
queries, a form. The action gets the page through [FromContent], and other parameters bind as
usual.
using Microsoft.AspNetCore.Mvc;
using MySite.Models;
using Relatude.DB.CMS.Web;
using Relatude.DB.CMS.Web.Rendering;
// from RenderMvcController<INewsList>("News") or a controller template
public class NewsController(RelatudeCmsContext ctx) : Controller {
public IActionResult Index([FromContent] INewsList list, int page = 0) {
var articles = ctx.DB.Query<IArticle>().Page(page, list.PageSize).Execute();
return View(new NewsListModel(list, [.. articles], articles.TotalCount));
}
}
public record NewsListModel(INewsList List, IArticle[] Articles, int TotalCount);The controller is reached through the page's URL, not a route of its own. Leave out [Route] and
[ApiController]: an action with attribute routing cannot be reached this way.