ASP.NET Core MVC Integration
ASP.NET Core MVC is a legacy configuration path for existing applications that already use server-side rendering and integrated server-side RecroGrid Framework behavior.
For new projects, prefer the Server-side Application model, which uses a Blazor host, SessionAuth, and server-side proxying in front of a separate backend API application.
How MVC differs from the newer models
From both deployment and development perspectives, the MVC integration is one server-side application. It keeps UI hosting, the RecroGrid Framework server runtime, business logic, and data access inside the same application boundary.
That means:
- it does not rely on a separate backend API application;
- the MVC app itself hosts the RGF runtime, data access, and the related UI integration;
- newer Blazor-based application models separate the interactive client from the main backend API responsibilities.
Register RecroGrid Framework services
Open Program.cs and register the RecroGrid Framework services in the web application.
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllersWithViews();
builder.AddRGF();
builder.AddBaseDbContext();
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseRGF<BaseDbContext, BaseDbContextPool, BaseDbContextPool>();
app.MapRazorPages();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();
Layout integration
The existing MVC layout can host RecroGrid Framework resources and menu rendering through the integrated server-side extension points already used by MVC applications.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - RGF.DemoMVC</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/RGF.DemoMVC.styles.css" asp-append-version="true" />
<link rel="stylesheet" href="/rgf/resource/bootstrap-submenu.css" />
<link rel="stylesheet" href="@($"/_content/recrogrid/lib/jqueryui/themes/{Recrovit.RecroGridFramework.RecroGridConfig.GetJQueryUIThemeName(this.Context)}/jquery-ui.css")" />
@await RenderSectionAsync("htmlhead", required: false)
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">RGF.DemoMVC</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1 rgf-menu">
@Html.Raw(await Recrovit.RecroGridFramework.UI.MenuDesigner.CreateNavbarAsync(this.Context))
</ul>
<partial name="_LoginPartial" />
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>
<footer class="border-top footer text-muted">
<div class="container">
RGF.DemoMVC - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
<script src="/_content/recrogrid/lib/jqueryui/jquery-ui.min.js"></script>
@Html.Raw(Recrovit.RecroGridFramework.RecroGrid.GetRecroGridScriptReferences(this.Context))
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>