Table of Contents

ASP.NET Core Web App MVC

Register RecroGrid Framework Services

Open Program.cs file and register the RecroGrid Framework Services in the web app.

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddControllersWithViews();

builder.AddRGF();
builder.AddBaseDbContext();

var app = builder.Build();

// Configure the HTTP request pipeline.
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();
<!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" />@*Highlight*@
    <link rel="stylesheet" href="@($"/_content/recrogrid/lib/jqueryui/themes/{Recrovit.RecroGridFramework.RecroGridConfig.GetJQueryUIThemeName(this.Context)}/jquery-ui.css")" />@*Highlight*@
    @await RenderSectionAsync("htmlhead", required: false)@*Highlight*@
</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">@*Highlight*@
                        @Html.Raw(await Recrovit.RecroGridFramework.UI.MenuDesigner.CreateNavbarAsync(this.Context))@*Highlight*@
                    </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>@*Highlight*@
    @Html.Raw(Recrovit.RecroGridFramework.RecroGrid.GetRecroGridScriptReferences(this.Context))@*Highlight*@
    @await RenderSectionAsync("Scripts", required: false)@*Highlight*@
</body>
</html>

See Also